Skip to content

Commit 4079ede

Browse files
committed
Added SAMA Compliance related changes and show nist and sama based on the ProfilePreferences
1 parent 57e4f7d commit 4079ede

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

appknox/analyses.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ type Analysis struct {
107107
Masvs []string `json:"masvs,omitempty"`
108108
Nistsp80053 []string `json:"nistsp80053,omitempty"`
109109
Nistsp800171 []string `json:"nistsp800171,omitempty"`
110+
Sama []string `json:"sama,omitempty"`
110111
Owaspmobile2024 []string `json:"owaspmobile2024,omitempty"`
111112
Findings []Finding `json:"findings,omitempty"`
112113
UpdatedOn *time.Time `json:"updated_on,omitempty"`

appknox/analyses_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func TestAnalysesCompliance_marshall(t *testing.T) {
4949
Masvs: []string{"MASVS_6_3"},
5050
Nistsp80053: []string{"AC_3", "RA_2"},
5151
Nistsp800171: []string{"3_1_1", "3_1_3"},
52+
Sama: []string{"3_3_6"},
5253
Owaspmobile2024: []string{"M6_2024"},
5354
VulnerabilityID: 1,
5455
}
@@ -65,6 +66,7 @@ func TestAnalysesCompliance_marshall(t *testing.T) {
6566
"masvs": ["MASVS_6_3"],
6667
"nistsp80053": ["AC_3", "RA_2"],
6768
"nistsp800171": ["3_1_1", "3_1_3"],
69+
"sama": ["3_3_6"],
6870
"owaspmobile2024": ["M6_2024"],
6971
"vulnerability": 1
7072
}`

appknox/project_profile.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type ProjectProfileReportPreference struct {
1818
ShowPcidss RegulatoryPreference `json:"show_pcidss,omitempty"`
1919
ShowHipaa RegulatoryPreference `json:"show_hipaa,omitempty"`
2020
ShowGdpr RegulatoryPreference `json:"show_gdpr,omitempty"`
21+
ShowNist RegulatoryPreference `json:"show_nist,omitempty"`
22+
ShowSama RegulatoryPreference `json:"show_sama,omitempty"`
2123
}
2224

2325
// CurrentAuthenticatedUser is used to get the details about the current

appknox/project_profile_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,21 @@ func TestRegulatoryPreference_marshall(t *testing.T) {
1818
}
1919
func TestProjectProfileReportPreference_marshall(t *testing.T) {
2020
testJSONMarshal(t, &ProjectProfileReportPreference{},
21-
`{"show_pcidss":{}, "show_hipaa":{}, "show_gdpr":{}}`)
21+
`{"show_pcidss":{}, "show_hipaa":{}, "show_gdpr":{}, "show_nist":{}, "show_sama":{}}`)
2222

2323
u := &ProjectProfileReportPreference{
2424
ShowPcidss: RegulatoryPreference{Value: true},
2525
ShowHipaa: RegulatoryPreference{Value: true},
2626
ShowGdpr: RegulatoryPreference{Value: true},
27+
ShowNist: RegulatoryPreference{Value: true},
28+
ShowSama: RegulatoryPreference{Value: true},
2729
}
2830
want := `{
2931
"show_pcidss": {"value": true},
3032
"show_hipaa": {"value": true},
31-
"show_gdpr": {"value": true}
33+
"show_gdpr": {"value": true},
34+
"show_nist": {"value": true},
35+
"show_sama": {"value": true}
3236
}`
3337
testJSONMarshal(t, u, want)
3438
}
@@ -46,7 +50,9 @@ func TestProjectProfilesService_GetProjectProfileReportPreference(t *testing.T)
4650
fmt.Fprint(w, `{
4751
"show_pcidss": {"value": true},
4852
"show_hipaa": {"value": true},
49-
"show_gdpr": {"value": false}
53+
"show_gdpr": {"value": false},
54+
"show_nist": {"value": false},
55+
"show_sama": {"value": false}
5056
}`)
5157
})
5258

@@ -59,6 +65,8 @@ func TestProjectProfilesService_GetProjectProfileReportPreference(t *testing.T)
5965
ShowPcidss: RegulatoryPreference{Value: true},
6066
ShowHipaa: RegulatoryPreference{Value: true},
6167
ShowGdpr: RegulatoryPreference{Value: false},
68+
ShowNist: RegulatoryPreference{Value: false},
69+
ShowSama: RegulatoryPreference{Value: false},
6270
}
6371
if !reflect.DeepEqual(profileReportPreference, want) {
6472
t.Errorf("ProjectProfiles.GetProjectProfileReportPreference returned %+v, want %+v",

helper/analyses.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func ProcessAnalyses(fileID int) {
3636
// header is an interface because t.AddHeader only supports
3737
// interface elements
3838
header := []interface{}{"ID", "RISK", "STATUS", "CVSS-VECTOR", "CVSS-BASE", "CVSS-VERSION", "OWASP", "ASVS", "CWE",
39-
"MSTG", "OWASP API 2023", "OWASP MASVS (v2)", "NIST SP 800-53", "NIST SP 800-171", "OWASP MOBILE 2024"}
39+
"MSTG", "OWASP API 2023", "OWASP MASVS (v2)", "OWASP MOBILE 2024"}
4040
if profileReportPref.ShowPcidss.Value {
4141
header = append(header, "PCI-DSS")
4242
}
@@ -46,6 +46,13 @@ func ProcessAnalyses(fileID int) {
4646
if profileReportPref.ShowGdpr.Value {
4747
header = append(header, "GDPR")
4848
}
49+
if profileReportPref.ShowNist.Value {
50+
header = append(header, "NIST SP 800-53")
51+
header = append(header, "NIST SP 800-171")
52+
}
53+
if profileReportPref.ShowSama.Value {
54+
header = append(header, "SAMA")
55+
}
4956
header = append(header, "UPDATED-ON", "VULNERABILITY-ID")
5057
t.AddHeader(header...)
5158
for i := 0; i < len(finalAnalyses); i++ {
@@ -64,8 +71,6 @@ func ProcessAnalyses(fileID int) {
6471
finalAnalyses[i].Mstg,
6572
finalAnalyses[i].Owaspapi2023,
6673
finalAnalyses[i].Masvs,
67-
finalAnalyses[i].Nistsp80053,
68-
finalAnalyses[i].Nistsp800171,
6974
finalAnalyses[i].Owaspmobile2024,
7075
}
7176
if profileReportPref.ShowPcidss.Value {
@@ -77,6 +82,13 @@ func ProcessAnalyses(fileID int) {
7782
if profileReportPref.ShowGdpr.Value {
7883
row = append(row, finalAnalyses[i].Gdpr)
7984
}
85+
if profileReportPref.ShowNist.Value {
86+
row = append(row, finalAnalyses[i].Nistsp80053)
87+
row = append(row, finalAnalyses[i].Nistsp800171)
88+
}
89+
if profileReportPref.ShowSama.Value {
90+
row = append(row, finalAnalyses[i].Sama)
91+
}
8092
row = append(row, *finalAnalyses[i].UpdatedOn,
8193
finalAnalyses[i].VulnerabilityID)
8294
t.AddLine(row...)

0 commit comments

Comments
 (0)