Skip to content
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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

barv-jfrog
Copy link
Contributor

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • Updated the Contributing page / ReadMe page / CI Workflow files if needed.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

Copy link
Contributor

@attiasas attiasas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Improve PR details, Link related PRs
  2. Please add tests! there are multiple places to add them
  3. Take a look at my comments.
  4. Make sure the PM are aware of the output and approve the text and UI before merge

@@ -49,6 +49,7 @@ const (
IacScan SubScanType = "iac"
SastScan SubScanType = "sast"
SecretsScan SubScanType = "secrets"
MaliciousCodeScan SubScanType = "malicious_code"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add to GetAllSupportedScans and IsJASRequested

Comment on lines +25 to +26
MaliciousVulnerabilities []SourceCodeRow `json:"malicious_code"`
MaliciousViolations []SourceCodeRow `json:"maliciousViolations"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MaliciousVulnerabilities []SourceCodeRow `json:"malicious_code"`
MaliciousViolations []SourceCodeRow `json:"maliciousViolations"`
MaliciousVulnerabilities []SourceCodeRow `json:"maliciousCode"`
MaliciousViolations []SourceCodeRow `json:"maliciousViolations"`

make sure the formats are the same...

Comment on lines +164 to +170
if sjc.current == nil {
return results.ErrResetConvertor
}
maliciousSimpleJson, err := PrepareSimpleJsonJasIssues(sjc.entitledForJas, sjc.pretty, results.ScanResultsToRuns(maliciousFindings)...)
if err != nil || len(maliciousSimpleJson) == 0 {
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@@ -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
Copy link
Contributor

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.

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 {
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants