Skip to content

Conversation

@barv-jfrog
Copy link
Contributor

@barv-jfrog barv-jfrog commented Dec 4, 2025

  • 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.

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 malicious-scan can scan this pickles and show in a table what is the malicious code.


Example:

image

@barv-jfrog barv-jfrog requested a review from attiasas December 8, 2025 14:35
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 9, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 9, 2025
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.

Nice work, Check out my comments:

  1. Update branch, merge dev and fix conflicts
  2. Make sure tests are passing after updating the AM version and running them
  3. Don't forget to merge dependent PR and update replaces before merging.
  4. Update PR description

// Expected number of Secrets issues
Secrets int
// Expected number of Malicious Code issues
MaliciousCode int
Copy link
Contributor

Choose a reason for hiding this comment

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

you added the expected malicious code issues but you are not using it.
you need to add code to ValidateScanTypeCount as well

Copy link
Contributor Author

@barv-jfrog barv-jfrog Dec 15, 2025

Choose a reason for hiding this comment

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

I do use it, why do I have to add to ValidateScanTypeCount?

Comment on lines 149 to 155
if cmd.customAnalyzerManagerPath != "" {
scanner.AnalyzerManager.AnalyzerManagerFullPath = cmd.customAnalyzerManagerPath
} else {
if scanner.AnalyzerManager.AnalyzerManagerFullPath, err = jas.GetAnalyzerManagerExecutable(); err != nil {
return fmt.Errorf("failed to set analyzer manager executable path: %w", err)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

if custom path is not empty (provided) we don't need to download the AM to the default dir...
similar to audit:

if cmd.customAnalyzerManagerPath == "" {
			if generalError = jas.DownloadAnalyzerManagerIfNeeded(threadId); generalError != nil {
				return fmt.Errorf("failed to download analyzer manager: %s", generalError.Error())
			}
			if scanner.AnalyzerManager.AnalyzerManagerFullPath, generalError = jas.GetAnalyzerManagerExecutable(); generalError != nil {
				return fmt.Errorf("failed to set analyzer manager executable path: %s", generalError.Error())
			}
		} else {
			scanner.AnalyzerManager.AnalyzerManagerFullPath = cmd.customAnalyzerManagerPath
			log.Debug(clientutils.GetLogMsgPrefix(threadId, false) + "using custom analyzer manager binary path")
		}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 247 to 253
if len(workingDirs) == 0 {
currentDir, err := coreutils.GetWorkingDirectory()
if err != nil {
cmdResults.AddGeneralError(fmt.Errorf("failed to get current working directory: %w", err), false)
return
}
cmdResults.NewScanResults(results.ScanTarget{Target: currentDir, Name: filepath.Base(currentDir)})
Copy link
Contributor

Choose a reason for hiding this comment

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

not possiable, already has at least one value after coreutils.GetFullPathsWorkingDirs(cmd.workingDirs)

Suggested change
if len(workingDirs) == 0 {
currentDir, err := coreutils.GetWorkingDirectory()
if err != nil {
cmdResults.AddGeneralError(fmt.Errorf("failed to get current working directory: %w", err), false)
return
}
cmdResults.NewScanResults(results.ScanTarget{Target: currentDir, Name: filepath.Base(currentDir)})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right

}

if len(cmdResults.Targets) == 0 {
log.Warn("No scan targets were detected. Proceeding with empty scan...")
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
log.Warn("No scan targets were detected. Proceeding with empty scan...")
log.Warn("No scan targets were detected.")

you are returning here....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right

Comment on lines 227 to 248
func logScanPaths(workingDirs []string) {
if len(workingDirs) == 0 {
return
}
if len(workingDirs) == 1 {
log.Info("Scanning path:", workingDirs[0])
return
}
log.Info("Scanning paths:", strings.Join(workingDirs, ", "))
}
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
func logScanPaths(workingDirs []string) {
if len(workingDirs) == 0 {
return
}
if len(workingDirs) == 1 {
log.Info("Scanning path:", workingDirs[0])
return
}
log.Info("Scanning paths:", strings.Join(workingDirs, ", "))
}
func logScanPaths(workingDirs []string) {
if len(workingDirs) == 0 {
return
}
if len(workingDirs) == 1 {
log.Debug("Scanning path:", workingDirs[0])
return
}
log.Debug("Scanning paths:", strings.Join(workingDirs, ", "))
}

I would move it to DEBUG since we already outputing targets later in Info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 15, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 15, 2025
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 23, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 23, 2025
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.

Check out my comments.
Also, make sure test are passing after updating the AM version with the scanner code

return jas.CreateScannersConfigFile(mal.configFileName, configFileContent, jasutils.MaliciousCode)
}

func (mal *MaliciousScanManager) getExcludePatterns(exclusions ...string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

you have: jas.GetExcludePatterns use it insead or adjust it if needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can I use it without jfrogapps module?

Url, XrayUrl, user, password, accessToken, ServerId, Threads, InsecureTls,
},
MaliciousScan: {
Url, XrayUrl, user, password, accessToken, ServerId, Threads, InsecureTls, OutputFormat, MinSeverity, AnalyzerManagerCustomPath, WorkingDirs, scanProjectKey,
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add a similar flag with different description if command is not hidden

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 23, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 23, 2025
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 23, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 23, 2025
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 23, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 23, 2025
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 24, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 24, 2025
@barv-jfrog barv-jfrog changed the base branch from main to dev December 24, 2025 11:42
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 24, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 24, 2025
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 24, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 24, 2025
@barv-jfrog barv-jfrog requested a review from attiasas December 24, 2025 13:11
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Dec 24, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants