Skip to content

Commit 3bc7e94

Browse files
Surendrajatsammyjeng
authored andcommitted
Add NIST Compliance
Update NIST related changes
1 parent e28e96d commit 3bc7e94

File tree

23 files changed

+447
-371
lines changed

23 files changed

+447
-371
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ $ appknox reports create 4
133133
3
134134
135135
$ appknox reports download summary-csv 3
136-
Organization ID,Project ID,Application Name,Application Namespace,Platform,Version,Version Code,File ID,Test Case,Scan Type,Severity,Risk Override,CVSS Score,Findings,Description,Noncompliant Code Example,Compliant Solution,Business Implication,OWASP,CWE,MSTG,OWASP MASVS (v2),ASVS,PCI-DSS,GDPR,Created On
136+
Organization ID,Project ID,Application Name,Application Namespace,Platform,Version,Version Code,File ID,Test Case,Scan Type,Severity,Risk Override,CVSS Score,Findings,Description,Noncompliant Code Example,Compliant Solution,Business Implication,OWASP,CWE,MSTG,OWASP MASVS (v2),ASVS,PCI-DSS,GDPR,NIST SP 800-53,NIST SP 800-171,Created On
137137
1,1,MFVA,com.appknox.mfva,Android,1.1,1605631525,51,Broken SSL Trust Manager,Static,High,,6.9,"BluK8lNUoeHkNxZ3GVrKN9BP2
138138
NVWmfbtHDiJBOTbOEpCnsbMhc6T31t...(Truncated)
139139

appknox/client.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from appknox.mapper import Organization
3131
from appknox.mapper import OWASP
3232
from appknox.mapper import PCIDSS
33+
from appknox.mapper import NISTSP80053,NISTSP800171
3334
from appknox.mapper import PersonalToken
3435
from appknox.mapper import ProfileReportPreference
3536
from appknox.mapper import Project
@@ -436,6 +437,46 @@ def get_pcidss(self, pcidss_id: str) -> PCIDSS:
436437
pcidss = self.drf_api["v2/pcidsses"](pcidss_id).get()
437438
return mapper_drf_api(PCIDSS, pcidss)
438439

440+
@lru_cache(maxsize=1)
441+
def get_nistsp80053es(self) -> List[NISTSP80053]:
442+
nistsp80053_raw = self.drf_api["v2/nistsp80053s"]().get()
443+
nistsp80053 = self.paginated_drf_data(nistsp80053_raw, NISTSP80053)
444+
return nistsp80053
445+
446+
def get_nistsp80053(self, nistsp80053_id: str) -> NISTSP80053:
447+
"""
448+
Fetch nistsp80053 by ID
449+
450+
:param nistsp80053_id: nistsp80053 ID
451+
"""
452+
nistsp80053es = self.get_nistsp80053es()
453+
nistsp80053 = next((x for x in nistsp80053es if x.id == nistsp80053_id), None)
454+
if nistsp80053:
455+
return nistsp80053
456+
457+
nistsp80053 = self.drf_api["v2/nistsp80053s"](nistsp80053_id).get()
458+
return mapper_drf_api(NISTSP80053, nistsp80053)
459+
460+
@lru_cache(maxsize=1)
461+
def get_nistsp800171es(self) -> List[NISTSP800171]:
462+
nistsp800171_raw = self.drf_api["v2/nistsp800171s"]().get()
463+
nistsp800171 = self.paginated_drf_data(nistsp800171_raw, NISTSP800171)
464+
return nistsp800171
465+
466+
def get_nistsp800171(self, nistsp800171_id: str) -> NISTSP800171:
467+
"""
468+
Fetch nistsp800171 by ID
469+
470+
:param nistsp800171_id: nistsp800171 ID
471+
"""
472+
nistsp800171es = self.get_nistsp800171es()
473+
nistsp800171 = next((x for x in nistsp800171es if x.id == nistsp800171_id), None)
474+
if nistsp800171:
475+
return nistsp800171
476+
477+
nistsp800171 = self.drf_api["v2/nistsp800171s"](nistsp800171_id).get()
478+
return mapper_drf_api(NISTSP80053, nistsp800171)
479+
439480
def upload_file(self, file_data: str) -> int:
440481
"""
441482
Upload and scan a package and returns the file_id
@@ -542,6 +583,8 @@ def get_unselected_report_preference(self, file_id: int) -> list:
542583
unselected_report_pref.append(ReportPreferenceMapper["show_hipaa"])
543584
if not profile_report_preference.show_pcidss.value:
544585
unselected_report_pref.append(ReportPreferenceMapper["show_pcidss"])
586+
if not profile_report_preference.show_nist.value:
587+
unselected_report_pref.append(ReportPreferenceMapper["show_nist"])
545588
return unselected_report_pref
546589

547590
def list_reports(self, file_id: int) -> typing.List["Report"]:

appknox/mapper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def mapper_drf_api(model: type, resource: dict) -> object:
6969
"masvs",
7070
"asvs",
7171
"gdpr",
72+
"nistsp80053",
73+
"nistsp800171",
7274
"computed_risk",
7375
"overridden_risk",
7476
],
@@ -93,12 +95,17 @@ def mapper_drf_api(model: type, resource: dict) -> object:
9395

9496
PCIDSS = namedtuple("PCIDSS", ["id", "code", "title", "description"])
9597

98+
NISTSP80053 = namedtuple("NISTSP80053", ["id", "code", "title"])
99+
100+
NISTSP800171 = namedtuple("NISTSP800171", ["id", "code", "title"])
101+
96102
PersonalToken = namedtuple("AccessToken", ["name", "key"])
97103

98104
ReportPreferenceMapper = {
99105
"show_pcidss": "pcidss",
100106
"show_hipaa": "hipaa",
101107
"show_gdpr": "gdpr",
108+
"show_nist": "nist",
102109
}
103110

104111

@@ -112,6 +119,7 @@ class ProfileReportPreference:
112119
show_gdpr: ProfileReportPreferenceConfig
113120
show_hipaa: ProfileReportPreferenceConfig
114121
show_pcidss: ProfileReportPreferenceConfig
122+
show_nist: ProfileReportPreferenceConfig
115123

116124
@classmethod
117125
def from_json(cls, data):
@@ -121,6 +129,7 @@ def from_json(cls, data):
121129
show_pcidss=ProfileReportPreferenceConfig(
122130
value=data["show_pcidss"]["value"]
123131
),
132+
show_nist=ProfileReportPreferenceConfig(value=data["show_nist"]["value"]),
124133
)
125134

126135

@@ -146,6 +155,7 @@ class ReportPreference:
146155
"show_ignored_analyses",
147156
"show_hipaa",
148157
"show_pcidss",
158+
"show_nist",
149159
]
150160

151161
show_api_scan: bool
@@ -166,6 +176,7 @@ def from_json(cls, data: typing.Dict[str, typing.Any]) -> "ReportPreference":
166176
show_ignored_analyses=data["show_ignored_analyses"],
167177
show_hipaa=InheritedPreference.from_json(data["show_hipaa"]),
168178
show_pcidss=InheritedPreference.from_json(data["show_pcidss"]),
179+
show_nist=InheritedPreference.from_json(data["show_nist"]),
169180
)
170181

171182

appknox/tests/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def setUp(self):
2525
"show_ignored_analyses": True,
2626
"show_hipaa": {"value": True, "is_inherited": True},
2727
"show_pcidss": {"value": True, "is_inherited": True},
28+
"show_nist": {"value": False, "is_inherited": True},
2829
}
2930
with mock.patch.object(Appknox, "get_organizations", self.get_org_list):
3031
self.ap_client = Appknox(

docs/.doctrees/client.doctree

5.78 KB
Binary file not shown.

docs/.doctrees/environment.pickle

31.8 KB
Binary file not shown.

docs/.doctrees/index.doctree

-3.36 KB
Binary file not shown.

docs/.doctrees/mapper.doctree

12.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)