Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ $ appknox reports create 4
3

$ appknox reports download summary-csv 3
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
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,SAMA,Created On
1,1,MFVA,com.appknox.mfva,Android,1.1,1605631525,51,Broken SSL Trust Manager,Static,High,,6.9,"BluK8lNUoeHkNxZ3GVrKN9BP2
NVWmfbtHDiJBOTbOEpCnsbMhc6T31t...(Truncated)

Expand Down
22 changes: 22 additions & 0 deletions appknox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from appknox.mapper import Organization
from appknox.mapper import OWASP
from appknox.mapper import PCIDSS
from appknox.mapper import SAMA
from appknox.mapper import PersonalToken
from appknox.mapper import ProfileReportPreference
from appknox.mapper import Project
Expand Down Expand Up @@ -436,6 +437,25 @@ def get_pcidss(self, pcidss_id: str) -> PCIDSS:
pcidss = self.drf_api["v2/pcidsses"](pcidss_id).get()
return mapper_drf_api(PCIDSS, pcidss)

@lru_cache(maxsize=1)
def get_samas(self) -> List[SAMA]:
samas_raw = self.drf_api["v2/samas"]().get()
samas = self.paginated_drf_data(samas_raw, SAMA)
return samas

def get_sama(self, sama_id: str) -> SAMA:
"""
Fetch SAMA by ID

:param sama_id: sama ID
"""
samas = self.get_samas()
sama = next((x for x in samas if x.id == sama_id), None)
if sama:
return sama
sama = self.drf_api["v2/samas"](sama_id).get()
return mapper_drf_api(SAMA, sama)

def upload_file(self, file_data: str) -> int:
"""
Upload and scan a package and returns the file_id
Expand Down Expand Up @@ -542,6 +562,8 @@ def get_unselected_report_preference(self, file_id: int) -> list:
unselected_report_pref.append(ReportPreferenceMapper["show_hipaa"])
if not profile_report_preference.show_pcidss.value:
unselected_report_pref.append(ReportPreferenceMapper["show_pcidss"])
if not profile_report_preference.show_sama.value:
unselected_report_pref.append(ReportPreferenceMapper["show_sama"])
return unselected_report_pref

def list_reports(self, file_id: int) -> typing.List["Report"]:
Expand Down
12 changes: 11 additions & 1 deletion appknox/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def mapper_drf_api(model: type, resource: dict) -> object:
"masvs",
"asvs",
"gdpr",
"sama",
"computed_risk",
"overridden_risk",
],
Expand All @@ -93,12 +94,15 @@ def mapper_drf_api(model: type, resource: dict) -> object:

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

SAMA = namedtuple("SAMA", ["id", "code", "title", "description"])

PersonalToken = namedtuple("AccessToken", ["name", "key"])

ReportPreferenceMapper = {
"show_pcidss": "pcidss",
"show_hipaa": "hipaa",
"show_gdpr": "gdpr",
"show_sama": "sama",
}


Expand All @@ -112,7 +116,7 @@ class ProfileReportPreference:
show_gdpr: ProfileReportPreferenceConfig
show_hipaa: ProfileReportPreferenceConfig
show_pcidss: ProfileReportPreferenceConfig

show_sama: ProfileReportPreferenceConfig
@classmethod
def from_json(cls, data):
return cls(
Expand All @@ -121,6 +125,9 @@ def from_json(cls, data):
show_pcidss=ProfileReportPreferenceConfig(
value=data["show_pcidss"]["value"]
),
show_sama=ProfileReportPreferenceConfig(
value=data["show_sama"]["value"]
)
)


Expand All @@ -146,6 +153,7 @@ class ReportPreference:
"show_ignored_analyses",
"show_hipaa",
"show_pcidss",
"show_sama",
]

show_api_scan: bool
Expand All @@ -155,6 +163,7 @@ class ReportPreference:
show_ignored_analyses: bool
show_hipaa: InheritedPreference
show_pcidss: InheritedPreference
show_sama: InheritedPreference

@classmethod
def from_json(cls, data: typing.Dict[str, typing.Any]) -> "ReportPreference":
Expand All @@ -166,6 +175,7 @@ def from_json(cls, data: typing.Dict[str, typing.Any]) -> "ReportPreference":
show_ignored_analyses=data["show_ignored_analyses"],
show_hipaa=InheritedPreference.from_json(data["show_hipaa"]),
show_pcidss=InheritedPreference.from_json(data["show_pcidss"]),
show_sama=InheritedPreference.from_json(data["show_sama"]),
)


Expand Down
1 change: 1 addition & 0 deletions appknox/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def setUp(self):
"show_ignored_analyses": True,
"show_hipaa": {"value": True, "is_inherited": True},
"show_pcidss": {"value": True, "is_inherited": True},
"show_sama": {"value":False, "is_inherited": False},
}
with mock.patch.object(Appknox, "get_organizations", self.get_org_list):
self.ap_client = Appknox(
Expand Down
Binary file modified docs/.doctrees/client.doctree
Binary file not shown.
Binary file modified docs/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/.doctrees/index.doctree
Binary file not shown.
Binary file modified docs/.doctrees/mapper.doctree
Binary file not shown.
Loading