Skip to content

Commit

Permalink
Git Audit - Diff mode
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Jan 30, 2025
1 parent 0d5b0be commit d502603
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cli/docs/git/audit/help.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package audit

import (
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
)

func GetDescription() string {
return "Audit your local git repository project for security issues."
}

func GetArguments() []components.Argument {
return []components.Argument{{Name: "target", Description: `Diff mode, run git diff between the cwd commit to the given target commit and audit the differences.
You can specify a commit hash, a branch name a tag name or a reference like HEAD~1.`}}
}
6 changes: 6 additions & 0 deletions cli/gitcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func getGitNameSpaceCommands() []components.Command {

func GitAuditCmd(c *components.Context) error {
gitAuditCmd := audit.NewGitAuditCommand()

if len(c.Arguments) > 0 {
// Diff mode
gitAuditCmd.SetDiffTarget(c.Arguments[0])
}

// Set connection params
serverDetails, err := createServerDetailsWithConfigOffer(c)
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion commands/git/audit/gitauditparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (

type GitAuditParams struct {
// Git Params
source services.XscGitInfoContext
source services.XscGitInfoContext
diffTarget string
// Connection params
serverDetails *config.ServerDetails
// Violations params
Expand All @@ -37,6 +38,11 @@ func NewGitAuditParams() *GitAuditParams {
return &GitAuditParams{}
}

func (gap *GitAuditParams) SetDiffTarget(diffTarget string) *GitAuditParams {
gap.diffTarget = diffTarget
return gap
}

func (gap *GitAuditParams) SetServerDetails(serverDetails *config.ServerDetails) *GitAuditParams {
gap.serverDetails = serverDetails
return gap
Expand Down

0 comments on commit d502603

Please sign in to comment.