Skip to content

Commit ebc04e8

Browse files
committed
improve tests for new config profile
1 parent 5177512 commit ebc04e8

File tree

2 files changed

+64
-62
lines changed

2 files changed

+64
-62
lines changed
Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,27 @@
11
{
22
"profile_name": "default-profile",
33
"general_config": {
4-
"releases_repo": "https://repo.example.com/releases",
5-
"analyzer_manager_version": "1.2.3",
6-
"report_analytics": true,
7-
"exclude_patterns": ["*.log*", "*.tmp*"],
8-
"results_output_dir": "/path/to/results",
9-
"allow_partial_results": false
4+
"scanners_download_path": "https://repo.example.com/releases",
5+
"general_exclude_patterns": ["*.log*", "*.tmp*"],
6+
"fail_upon_any_scanner_error": true
107
},
118
"frogbot_config": {
12-
"email_author": "[email protected]",
139
"aggregate_fixes": true,
14-
"avoid_previous_pr_comments_deletion": true,
15-
"avoid_extra_messages": true,
16-
"add_success_comment": true,
10+
"hide_success_banner_for_no_issues": false,
1711
"branch_name_template": "frogbot-${IMPACTED_PACKAGE}-${BRANCH_NAME_HASH}",
1812
"pr_title_template": "[🐸 Frogbot] Upgrade {IMPACTED_PACKAGE} to {FIX_VERSION}",
19-
"pr_comment_title": "Frogbot notes:",
2013
"commit_message_template": "Upgrade {IMPACTED_PACKAGE} to {FIX_VERSION}",
2114
"show_secrets_as_pr_comment": false,
22-
"skip_auto_fix": false,
23-
"include_all_repository_vulnerabilities": true
15+
"create_auto_fix_pr": true,
16+
"include_vulnerabilities_and_violations": false
2417
},
2518
"modules": [
2619
{
2720
"module_name": "default-module",
2821
"path_from_root": ".",
29-
"exclude_patterns": ["**/.git/**", "**/*test*/**", "**/*venv*/**", "**/*node_modules*/**", "**/target/**"],
3022
"scan_config": {
3123
"sca_scanner_config": {
3224
"enable_sca_scan": true,
33-
"technology": "Java",
34-
"package_managers_settings": {
35-
"gradle_settings": {
36-
"exclude_test_deps": false,
37-
"use_wrapper": true
38-
},
39-
"maven_settings": {
40-
"use_wrapper": true
41-
},
42-
"npm_settings": {
43-
"dep_type": "all",
44-
"pnpm_max_tree_depth": 9
45-
},
46-
"python_settings": {
47-
"requirements_file": "requirements.txt"
48-
}
49-
},
50-
"skip_auto_install": true,
5125
"exclude_patterns": ["**/build/**"]
5226
},
5327
"contextual_analysis_scanner_config": {
@@ -56,26 +30,20 @@
5630
},
5731
"sast_scanner_config": {
5832
"enable_sast_scan": true,
59-
"language": "Java",
60-
"include_patterns": ["*.go"],
6133
"exclude_patterns": ["**/_test.go/**"],
6234
"exclude_rules": ["xss-injection"]
6335
},
6436
"secrets_scanner_config": {
6537
"enable_secrets_scan": true,
6638
"validate_secrets": true,
67-
"include_patterns": ["*.go"],
68-
"exclude_patterns": ["**/_test.go/**"]
39+
"exclude_patterns": ["**/_test.go/**"],
40+
"enable_custom_secrets": true
6941
},
7042
"iac_scanner_config": {
7143
"enable_iac_scan": true,
72-
"include_patterns": ["*.tf"],
7344
"exclude_patterns": ["*.tfstate"]
7445
}
75-
},
76-
"deps_repo": "https://deps.example.com"
46+
}
7747
}
78-
],
79-
"is_default": true,
80-
"is_basic_profile": false
48+
]
8149
}

utils/xsc/configprofile_test.go

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package xsc
22

33
import (
4-
"encoding/json"
5-
"os"
64
"testing"
75

86
"github.com/jfrog/jfrog-cli-security/tests/validations"
@@ -44,15 +42,7 @@ func TestGetConfigProfileByName(t *testing.T) {
4442
}
4543
// Validate results
4644
assert.NoError(t, err)
47-
48-
profileFileContent, err := os.ReadFile("../../tests/testdata/other/configProfile/configProfileExample.json")
49-
assert.NoError(t, err)
50-
51-
var configProfileForComparison services.ConfigProfile
52-
err = json.Unmarshal(profileFileContent, &configProfileForComparison)
53-
assert.NoError(t, err)
54-
55-
assert.Equal(t, &configProfileForComparison, configProfile)
45+
assert.Equal(t, getComparisonConfigProfile(), configProfile)
5646
})
5747
}
5848
}
@@ -87,15 +77,59 @@ func TestGetConfigProfileByUrl(t *testing.T) {
8777
}
8878
// Validate results
8979
assert.NoError(t, err)
90-
91-
profileFileContent, err := os.ReadFile("../../tests/testdata/other/configProfile/configProfileExample.json")
92-
assert.NoError(t, err)
93-
94-
var configProfileForComparison services.ConfigProfile
95-
err = json.Unmarshal(profileFileContent, &configProfileForComparison)
96-
assert.NoError(t, err)
97-
98-
assert.Equal(t, &configProfileForComparison, configProfile)
80+
assert.Equal(t, getComparisonConfigProfile(), configProfile)
9981
})
10082
}
10183
}
84+
85+
func getComparisonConfigProfile() *services.ConfigProfile {
86+
return &services.ConfigProfile{
87+
ProfileName: "default-profile",
88+
GeneralConfig: services.GeneralConfig{
89+
ScannersDownloadPath: "https://repo.example.com/releases",
90+
GeneralExcludePatterns: []string{"*.log*", "*.tmp*"},
91+
FailUponAnyScannerError: true,
92+
},
93+
FrogbotConfig: services.FrogbotConfig{
94+
AggregateFixes: true,
95+
HideSuccessBannerForNoIssues: false,
96+
BranchNameTemplate: "frogbot-${IMPACTED_PACKAGE}-${BRANCH_NAME_HASH}",
97+
PrTitleTemplate: "[🐸 Frogbot] Upgrade {IMPACTED_PACKAGE} to {FIX_VERSION}",
98+
CommitMessageTemplate: "Upgrade {IMPACTED_PACKAGE} to {FIX_VERSION}",
99+
ShowSecretsAsPrComment: false,
100+
CreateAutoFixPr: true,
101+
IncludeVulnerabilitiesAndViolations: false,
102+
},
103+
Modules: []services.Module{
104+
{
105+
ModuleName: "default-module",
106+
PathFromRoot: ".",
107+
ScanConfig: services.ScanConfig{
108+
ScaScannerConfig: services.ScaScannerConfig{
109+
EnableScaScan: true,
110+
ExcludePatterns: []string{"**/build/**"},
111+
},
112+
ContextualAnalysisScannerConfig: services.CaScannerConfig{
113+
EnableCaScan: true,
114+
ExcludePatterns: []string{"**/docs/**"},
115+
},
116+
SastScannerConfig: services.SastScannerConfig{
117+
EnableSastScan: true,
118+
ExcludePatterns: []string{"**/_test.go/**"},
119+
ExcludeRules: []string{"xss-injection"},
120+
},
121+
SecretsScannerConfig: services.SecretsScannerConfig{
122+
EnableSecretsScan: true,
123+
ValidateSecrets: true,
124+
ExcludePatterns: []string{"**/_test.go/**"},
125+
EnableCustomSecrets: true,
126+
},
127+
IacScannerConfig: services.IacScannerConfig{
128+
EnableIacScan: true,
129+
ExcludePatterns: []string{"*.tfstate"},
130+
},
131+
},
132+
},
133+
},
134+
}
135+
}

0 commit comments

Comments
 (0)