Documentation
¶
Index ¶
- Constants
- Variables
- func DownloadResourceFromPlatformIfNeeded(resourceName, downloadPath, targetDir, targetArtifactName string, ...) error
- func DumpCdxContentToFile(bom *cyclonedx.BOM, scanResultsOutputDir, filePrefix string, threadId int) (pathToSave string, err error)
- func DumpCdxJsonContentToFile(fileContent []byte, scanResultsOutputDir, filePrefix string, threadId int) (resultsFileFullPath string, err error)
- func DumpContentToFile(fileContent []byte, scanResultsOutputDir string, prefix, suffix string, ...) (resultsFileFullPath string, err error)
- func DumpJsonContentToFile(fileContent []byte, scanResultsOutputDir string, scanType string, threadId int) (err error)
- func DumpSarifContentToFile(fileContent []byte, scanResultsOutputDir string, scanType string, threadId int) (err error)
- func ElementsEqual[T comparable](slice1 []T, slice2 []T) bool
- func FileSha256(filePath string) (string, error)
- func GetAsJsonBytes(output interface{}, escapeValues, indent bool) (results []byte, err error)
- func GetAsJsonString(output interface{}, escapeValues, indent bool) (string, error)
- func GetCommonParentDir(paths ...string) string
- func GetContributorsCacheDir() (string, error)
- func GetCurationCacheFolder() (string, error)
- func GetCurationCacheFolderByTech(tech string) (projectDir string, err error)
- func GetCurationNugetCacheFolder() (string, error)
- func GetCurationPipCacheFolder() (string, error)
- func GetCurrentTimeUnix() string
- func GetExcludePattern(excludePatterns []string, defaultExcludePatterns []string, isRecursive bool) string
- func GetFullPathsWorkingDirs(workingDirs []string) ([]string, error)
- func GetGitRepoUrlKey(gitRepoHttpsCloneUrl string) string
- func GetRelativePath(fullPathWd, baseWd string) string
- func GetReleasesRemoteDetails(artifact, downloadPath, remoteRepo string, ...) (server *config.ServerDetails, fullRemotePath string, err error)
- func GetRepositoriesScansListUrlForArtifact(baseUrl, repoPath, artifactName, packageID string) string
- func GetScanFindingsLog(scanType SubScanType, vulnerabilitiesCount int, scanStartTime time.Time, ...) string
- func GetScanStartLog(scanType SubScanType, target string, targetCount, threadId int) string
- func IsCI() bool
- func IsPathExcluded(path string, exclusions []string) bool
- func IsPathMatchesPatterns(rootPath, path string, isRecursive, fromRelativePath bool, patterns ...string) bool
- func IsScanRequested(cmdType CommandType, subScan SubScanType, centralConfigRequestedParam *bool, ...) bool
- func ListDirs(rootPath string, isRecursive, patternsFromRelativePath, preserveSymlink bool, ...) (dirs []string, err error)
- func ListFilesAndDirs(rootPath string, isRecursive, excludeWithRelativePath, preserveSymlink bool, ...) (files, dirs []string, err error)
- func Md5Hash(values ...string) (string, error)
- func MergeMaps(maps ...map[string]string) map[string]string
- func NewBoolPtr(v bool) *bool
- func NewFloat64Ptr(v float64) *float64
- func NewInt64Ptr(v int64) *int64
- func NewIntPtr(v int) *int
- func NewStrPtr(v string) *string
- func NewStringPtr(v string) *string
- func ReadSbomFromFile(cdxFilePath string) (bom *cyclonedx.BOM, err error)
- func SaveCdxContentToFile(pathToSave string, bom *cyclonedx.BOM) (err error)
- func Sha1Hash(values ...string) (string, error)
- func Sha256Hash(values ...string) (string, error)
- func ToCommandEnvVars(envVarsMap map[string]string) (converted []string)
- func ToEnvVarsMap(envVars []string) (converted map[string]string)
- func ToURI(path string) string
- func UniqueIntersection[T comparable](arr []T, others ...T) []T
- func UniqueUnion[T comparable](arr []T, elements ...T) []T
- type CommandType
- type LineDecoratorWriter
- type SecurityParallelRunner
- type SubScanType
Constants ¶
const ( JfrogCurationDirName = "curation" JfrogContributorsDirName = "contributors-cache" CurationsDir = "JFROG_CLI_CURATION_DIR" // #nosec G101 -- Not credentials. CurationSupportFlag = "JFROG_CLI_CURATION" )
const ( NodeModulesPattern = "**/*node_modules*/**" JfMsiEnvVariable = "JF_MSI" BaseDocumentationURL = "https://docs.jfrog.com/security/docs/" JasInfoURL = BaseDocumentationURL + "advanced-security" EntitlementsMinVersion = "3.66.5" GitRepoKeyAnalyticsMinVersion = "3.114.0" StaticScanMinVersion = "3.133.0" XrayToolName = "JFrog Xray Scanner" JfrogExternalRunIdEnv = "JFROG_CLI_USAGE_RUN_ID" JfrogExternalJobIdEnv = "JFROG_CLI_USAGE_JOB_ID" JfrogExternalGitRepoEnv = "JFROG_CLI_USAGE_GIT_REPO" CurrentGithubWorkflowNameEnvVar = "GITHUB_WORKFLOW" CurrentGithubWorkflowRunNumberEnvVar = "GITHUB_RUN_NUMBER" CurrentGithubWorkflowWorkspaceEnvVar = "GITHUB_WORKSPACE" CurrentGithubWorkflowJobEnvVar = "GITHUB_JOB" CurrentGithubShaEnvVar = "GITHUB_SHA" IsAllowEmojis = "JF_ALLOW_EMOJIS" )
Variables ¶
var ( // Exclude pattern for files. DefaultJasExcludePatterns = []string{"**/.git/**", "**/*test*/**", "**/*venv*/**", NodeModulesPattern, "**/target/**", "**/dist/**"} // Exclude pattern for directories. DefaultScaExcludePatterns = []string{"*.git*", "*node_modules*", "*target*", "*venv*", "*test*", "dist"} )
Functions ¶
func DownloadResourceFromPlatformIfNeeded ¶ added in v1.21.7
func DumpCdxContentToFile ¶ added in v1.20.0
func DumpCdxJsonContentToFile ¶ added in v1.23.0
func DumpContentToFile ¶ added in v1.9.0
func DumpJsonContentToFile ¶ added in v1.20.0
func DumpSarifContentToFile ¶ added in v1.20.0
func ElementsEqual ¶ added in v1.29.3
func ElementsEqual[T comparable](slice1 []T, slice2 []T) bool
func FileSha256 ¶ added in v1.20.0
func GetAsJsonBytes ¶ added in v1.12.0
func GetAsJsonString ¶ added in v1.12.0
func GetCommonParentDir ¶ added in v1.18.0
Calculate the common parent directory of the given paths. Examples:
- [dir] -> dir
- [dir/dir, dir/directory] -> dir
- [dir, directory] -> "."
- [dir/dir2, dir/dir2/dir3, dir/dir2/dir3/dir4] -> dir/dir2
func GetContributorsCacheDir ¶ added in v1.29.0
func GetCurationCacheFolder ¶ added in v1.0.4
func GetCurationCacheFolderByTech ¶ added in v1.3.0
func GetCurationNugetCacheFolder ¶ added in v1.8.1
func GetCurationPipCacheFolder ¶ added in v1.1.0
func GetCurrentTimeUnix ¶ added in v1.20.0
func GetCurrentTimeUnix() string
func GetExcludePattern ¶ added in v1.29.3
func GetFullPathsWorkingDirs ¶ added in v1.29.3
func GetGitRepoUrlKey ¶ added in v1.15.0
Returns the key for the git reop Url, as expected by the Analyzer Manager and the Analytics event report
func GetRelativePath ¶ added in v1.18.0
func GetReleasesRemoteDetails ¶ added in v1.20.0
func GetReleasesRemoteDetails(artifact, downloadPath, remoteRepo string, remoteServerDetails *config.ServerDetails) (server *config.ServerDetails, fullRemotePath string, err error)
func GetRepositoriesScansListUrlForArtifact ¶ added in v1.20.0
func GetScanFindingsLog ¶ added in v1.14.0
func GetScanStartLog ¶ added in v1.23.0
func GetScanStartLog(scanType SubScanType, target string, targetCount, threadId int) string
func IsPathExcluded ¶ added in v1.29.3
func IsPathMatchesPatterns ¶ added in v1.29.3
func IsScanRequested ¶ added in v1.12.0
func IsScanRequested(cmdType CommandType, subScan SubScanType, centralConfigRequestedParam *bool, requestedScans ...SubScanType) bool
IsScanRequested returns true if the scan is requested, otherwise false. If requestedScans is empty, all scans are considered requested.
func ListFilesAndDirs ¶ added in v1.29.3
func MergeMaps ¶ added in v1.5.0
Merge multiple maps into one, the last map will override the previous ones
func NewBoolPtr ¶ added in v1.12.0
func NewFloat64Ptr ¶ added in v1.12.0
func NewInt64Ptr ¶ added in v1.12.0
func NewStringPtr ¶ added in v1.13.7
func ReadSbomFromFile ¶ added in v1.20.0
func SaveCdxContentToFile ¶ added in v1.20.0
func Sha256Hash ¶ added in v1.20.0
func ToCommandEnvVars ¶ added in v1.5.0
map[string]string to []string (key=value format)
func ToEnvVarsMap ¶ added in v1.5.0
[]string (key=value format) to map[string]string
func UniqueIntersection ¶ added in v1.12.0
func UniqueIntersection[T comparable](arr []T, others ...T) []T
UniqueIntersection returns a new slice of strings that contains elements from both input slices without duplicates
func UniqueUnion ¶ added in v1.12.0
func UniqueUnion[T comparable](arr []T, elements ...T) []T
UniqueUnion returns a new slice of strings that contains elements from the input slice and the elements provided without duplicates
Types ¶
type CommandType ¶ added in v1.8.0
type CommandType string
const ( SourceCode CommandType = "source_code" Binary CommandType = "binary" DockerImage CommandType = "docker_image" Build CommandType = "build" Curation CommandType = "curation" SBOM CommandType = "SBOM" )
func (CommandType) IsTargetBinary ¶ added in v1.8.0
func (s CommandType) IsTargetBinary() bool
type LineDecoratorWriter ¶ added in v1.26.2
type LineDecoratorWriter struct {
// contains filtered or unexported fields
}
LineDecoratorWriter is a line decorator that writes each line to the underlying writer with an optional prefix and suffix.
func NewLineDecoratorWriter ¶ added in v1.26.2
func NewLineDecoratorWriter(w io.Writer, prefix, suffix string) *LineDecoratorWriter
NewLineDecoratorWriter returns a writer that decorates each line with the given prefix and suffix. Use empty string for prefix or suffix to omit. E.g. NewLineDecoratorWriter(w, "{", "}") wraps each line as "{ line }".
type SecurityParallelRunner ¶ added in v1.4.0
type SecurityParallelRunner struct {
Runner parallel.Runner
ResultsMu sync.Mutex
ScaScansWg sync.WaitGroup // Verify that the sca scan routines are done before running contextual scan
JasScannersWg sync.WaitGroup // Verify that all scanners routines are done before cleaning temp dir
JasWg sync.WaitGroup // Verify that downloading analyzer manager and running all scanners are done
// contains filtered or unexported fields
}
func CreateSecurityParallelRunner ¶ added in v1.4.0
func CreateSecurityParallelRunner(numOfParallelScans int) *SecurityParallelRunner
func NewSecurityParallelRunner ¶ added in v1.4.0
func NewSecurityParallelRunner(numOfParallelScans int) SecurityParallelRunner
func (*SecurityParallelRunner) OnScanEnd ¶ added in v1.20.0
func (spr *SecurityParallelRunner) OnScanEnd(funcToRunOnScanEnd func()) *SecurityParallelRunner
func (*SecurityParallelRunner) Start ¶ added in v1.20.0
func (spr *SecurityParallelRunner) Start()
type SubScanType ¶ added in v1.4.0
type SubScanType string
const ( ContextualAnalysisScan SubScanType = "contextual_analysis" ScaScan SubScanType = "sca" IacScan SubScanType = "iac" SastScan SubScanType = "sast" SecretsScan SubScanType = "secrets" SecretTokenValidationScan SubScanType = "secrets_token_validation" MaliciousCodeScan SubScanType = "malicious_code" )
func GetAllSupportedScans ¶ added in v1.4.0
func GetAllSupportedScans() []SubScanType
func (SubScanType) String ¶ added in v1.4.0
func (s SubScanType) String() string
func (SubScanType) ToTextString ¶ added in v1.20.0
func (subScan SubScanType) ToTextString() string