Exemple #1
0
    def to_dict(self) -> Dict:
        """Serialize the response model to a Python dict.

        :return: A dict holding the request model data
        """
        d = {
            "id": self.identifier,
            "name": self.name,
            "createdAt": serialize_api_timestamp(self.created_at),
            "createdBy": self.created_by,
            "completedAt": serialize_api_timestamp(self.completed_at),
            "progress": self.progress,
            "mainSourceFiles": self.main_source_files,
            "status": self.status.lower(),
            "numAnalyses": self.analysis_statistics.to_dict(),
            "numVulnerabilities": self.vulnerability_statistics.to_dict(),
        }
        return d
Exemple #2
0
def assert_analysis(expected, analysis):
    assert analysis.uuid == expected["uuid"]
    assert analysis.api_version == expected["apiVersion"]
    assert analysis.mythril_version == expected["mythrilVersion"]
    assert analysis.maru_version == expected["maruVersion"]
    assert analysis.run_time == expected["runTime"]
    assert analysis.queue_time == expected["queueTime"]
    assert analysis.status == AnalysisStatus(expected["status"])
    assert serialize_api_timestamp(analysis.submitted_at) == expected["submittedAt"]
    assert analysis.submitted_by == expected["submittedBy"]
Exemple #3
0
def assert_analysis(analysis):
    assert analysis.uuid == testdata.UUID_1
    assert analysis.api_version == testdata.API_VERSION_1
    assert analysis.mythril_version == testdata.MYTHRIL_VERSION_1
    assert analysis.maru_version == testdata.MARU_VERSION_1
    assert analysis.run_time == testdata.RUN_TIME_1
    assert analysis.queue_time == testdata.QUEUE_TIME_1
    assert analysis.status == AnalysisStatus(testdata.STATUS_1)
    assert serialize_api_timestamp(
        analysis.submitted_at) == testdata.SUBMITTED_AT_1
    assert analysis.submitted_by == testdata.SUBMITTED_BY_1
def assert_analysis_data(analysis: Analysis):
    assert DICT_DATA["apiVersion"] == analysis.api_version
    assert DICT_DATA["maruVersion"] == analysis.maru_version
    assert DICT_DATA["mythrilVersion"] == analysis.mythril_version
    assert DICT_DATA["harveyVersion"] == analysis.harvey_version
    assert DICT_DATA["queueTime"] == analysis.queue_time
    assert DICT_DATA["runTime"] == analysis.run_time
    assert DICT_DATA["status"] == analysis.status
    assert DICT_DATA["submittedAt"] == serialize_api_timestamp(
        analysis.submitted_at)
    assert DICT_DATA["submittedBy"] == analysis.submitted_by
    assert DICT_DATA["uuid"] == analysis.uuid
def assert_analysis_data(expected, analysis: Analysis):
    assert expected["apiVersion"] == analysis.api_version
    assert expected["maruVersion"] == analysis.maru_version
    assert expected["mythrilVersion"] == analysis.mythril_version
    assert expected["harveyVersion"] == analysis.harvey_version
    assert expected["queueTime"] == analysis.queue_time
    assert expected["runTime"] == analysis.run_time
    assert expected["status"] == analysis.status
    assert expected["submittedAt"] == serialize_api_timestamp(
        analysis.submitted_at)
    assert expected["submittedBy"] == analysis.submitted_by
    assert expected["uuid"] == analysis.uuid
    assert expected["groupName"] == analysis.group_name
    assert expected["groupId"] == analysis.group_id
    assert expected["analysisMode"] == analysis.analysis_mode
Exemple #6
0
    def to_dict(self) -> Dict:
        """Serialize the response model to a Python dict.

        :return: A dict holding the request model data
        """
        d = {
            "uuid":
            self.uuid,
            "apiVersion":
            self.api_version,
            "mythrilVersion":
            self.mythril_version,
            "harveyVersion":
            self.harvey_version,
            "maruVersion":
            self.maru_version,
            "queueTime":
            self.queue_time,
            "runTime":
            self.run_time,
            "status":
            self.status.title(),
            "submittedAt":
            serialize_api_timestamp(self.submitted_at),
            "submittedBy":
            self.submitted_by,
            "mainSource":
            self.main_source,
            "numSources":
            self.num_sources,
            "numVulnerabilities":
            self.vulnerability_statistics.to_dict()
            if self.vulnerability_statistics else None,
            "clientToolName":
            self.client_tool_name,
            "analysisMode":
            self.analysis_mode,
            "groupName":
            self.group_name,
            "groupId":
            self.group_id,
        }
        if self.error is not None:
            d.update({"error": self.error})
        if self.info is not None:
            d.update({"info": self.error})

        return dict_delete_none_fields(d)
Exemple #7
0
    def to_dict(self):
        """Serialize the reponse model to a Python dict.

        :return: A dict holding the request model data
        """
        d = {
            "uuid": self.uuid,
            "apiVersion": self.api_version,
            "mythrilVersion": self.mythril_version,
            "harveyVersion": self.harvey_version,
            "maruVersion": self.maru_version,
            "queueTime": self.queue_time,
            "runTime": self.run_time,
            "status": self.status.title(),
            "submittedAt": serialize_api_timestamp(self.submitted_at),
            "submittedBy": self.submitted_by,
            "clientToolName": self.client_tool_name,
        }
        if self.error is not None:
            d.update({"error": self.error})

        return d
def test_ts_serde(api_ts, datetime_ts):
    assert deserialize_api_timestamp(api_ts) == datetime_ts
    assert serialize_api_timestamp(datetime_ts) == api_ts