-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Malicious code scanner #296
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Improve PR details, Link related PRs
- Please add tests! there are multiple places to add them
- Take a look at my comments.
- Make sure the PM are aware of the output and approve the text and UI before merge
utils/formats/simplejsonapi.go
Outdated
MaliciousVulnerabilities []SourceCodeRow `json:"malicious_code"` | ||
MaliciousViolations []SourceCodeRow `json:"maliciousViolations"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MaliciousVulnerabilities []SourceCodeRow `json:"malicious_code"` | |
MaliciousViolations []SourceCodeRow `json:"maliciousViolations"` | |
MaliciousVulnerabilities []SourceCodeRow `json:"maliciousCode"` | |
MaliciousViolations []SourceCodeRow `json:"maliciousViolations"` |
make sure the formats are the same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
if sjc.current == nil { | ||
return results.ErrResetConvertor | ||
} | ||
maliciousSimpleJson, err := PrepareSimpleJsonJasIssues(sjc.entitledForJas, sjc.pretty, results.ScanResultsToRuns(maliciousFindings)...) | ||
if err != nil || len(maliciousSimpleJson) == 0 { | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if sjc.current == nil { | |
return results.ErrResetConvertor | |
} | |
maliciousSimpleJson, err := PrepareSimpleJsonJasIssues(sjc.entitledForJas, sjc.pretty, results.ScanResultsToRuns(maliciousFindings)...) | |
if err != nil || len(maliciousSimpleJson) == 0 { | |
return | |
} | |
if sjc.current == nil { | |
return results.ErrResetConvertor | |
} | |
for i := range maliciousFindings { | |
if shouldUpdateStatus(sjc.current.Statuses.MaliciousStatusCode, &maliciousFindings[i].StatusCode) { | |
sjc.current.Statuses.MaliciousStatusCode = &maliciousFindings[i].StatusCode | |
} | |
} | |
maliciousSimpleJson, err := PrepareSimpleJsonJasIssues(sjc.entitledForJas, sjc.pretty, results.ScanResultsToRuns(maliciousFindings)...) | |
if err != nil || len(maliciousSimpleJson) == 0 { | |
return | |
} |
Add this scan to the status attributes so we can use it in all other places to display the command information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
go.mod
Outdated
@@ -114,7 +114,7 @@ require ( | |||
gopkg.in/warnings.v0 v0.1.2 // indirect | |||
) | |||
|
|||
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250126110945-81abbdde452f | |||
replace github.com/jfrog/jfrog-client-go => ../jfrog-client-go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for remote push, while developing, make sure you are pointing to a valid branch.
This is expceting the code to be in the machine locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
jas/runner/jasrunner.go
Outdated
if generalError = addJasScanTaskForModuleIfNeeded(params, utils.ContextualAnalysisScan, runContextualScan(params.Runner, params.Scanner, params.ScanResults, params.Module, params.DirectDependencies, params.ThirdPartyApplicabilityScan, params.ApplicableScanType, params.TargetOutputDir)); generalError != nil { | ||
return | ||
} | ||
//if generalError = addJasScanTaskForModuleIfNeeded(params, utils.ContextualAnalysisScan, runContextualScan(params.Runner, params.Scanner, params.ScanResults, params.Module, params.DirectDependencies, params.ThirdPartyApplicabilityScan, params.ApplicableScanType, params.TargetOutputDir)); generalError != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget to uncomment when done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, take a look at my comments, in addition:
- fix failed tests
- add description to the PR details, make sure to explain the type of scan and add screen shots so the users can understand and reference to.
- Add integration tests at audit_test.go that runs and validate a malicious issues on a project
{ | ||
"tool": { | ||
"driver": { | ||
"name": "JFrog Terraform scanner", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"name": "JFrog Terraform scanner", | |
"name": "JFrog Malicious Code scanner", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -102,6 +108,8 @@ func addJasScanTaskForModuleIfNeeded(params JasRunnerParams, subScan utils.SubSc | |||
enabled = params.ConfigProfile.Modules[0].ScanConfig.IacScannerConfig.EnableIacScan | |||
case jasutils.Applicability: | |||
enabled = params.ConfigProfile.Modules[0].ScanConfig.EnableContextualAnalysisScan | |||
case jasutils.MaliciousCode: | |||
enabled = params.ConfigProfile.Modules[0].ScanConfig.MaliciousScannerConfig.EnableMaliciousScan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we also added this to the config at the platform?
dev
branch.go vet ./...
.go fmt ./...
.depends on:
Description:
New malicious scanners which check for malicious code on the source code. For example, models such as pickle may contain malicious code in their code, so now jf audit can scan this pickles and show in a table what is the malicious code.
Example: