Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
heryxpc committed Jan 17, 2025
1 parent 75aa04f commit 5281e61
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 70 deletions.
2 changes: 2 additions & 0 deletions cartography/models/aws/inspector/findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class InspectorFindingToAWSAccount(CartographyRelSchema):
class InspectorFindingToAwsAccountDelegateRelProperties(CartographyRelProperties):
lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True)


@dataclass(frozen=True)
class InspectorFindingToAWSAccountDelegate(CartographyRelSchema):
target_node_label: str = 'AWSAccount'
Expand All @@ -75,6 +76,7 @@ class InspectorFindingToAWSAccountDelegate(CartographyRelSchema):
rel_label: str = "DELEGATE"
properties: InspectorFindingToAwsAccountDelegateRelProperties = InspectorFindingToAwsAccountDelegateRelProperties()


@dataclass(frozen=True)
class InspectorFindingToEC2InstanceRelProperties(CartographyRelProperties):
lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True)
Expand Down
136 changes: 68 additions & 68 deletions tests/data/aws/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,78 +191,78 @@
'type': 'PACKAGE_VULNERABILITY',
'updatedAt': datetime(2022, 5, 4, 16, 23, 3, 692000),
},
{
'awsAccountId': '123456789011',
'description': 'A buffer overflow vulnerability in OpenSSL allows remote attackers '
{
'awsAccountId': '123456789011',
'description': 'A buffer overflow vulnerability in OpenSSL allows remote attackers '
'to execute arbitrary code or cause a denial of service via crafted '
'SSL/TLS handshake messages.',
'findingArn': 'arn:aws:test789',
'firstObservedAt': datetime(2022, 5, 4, 16, 23, 3, 692000),
'inspectorScore': 7.5,
'inspectorScoreDetails': {
'adjustedCvss': {
'adjustments': [],
'cvssSource': 'NVD',
'score': 7.5,
'scoreSource': 'NVD',
'scoringVector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N',
'version': '3.1',
},
},
'lastObservedAt': datetime(2022, 5, 4, 16, 23, 3, 692000),
'packageVulnerabilityDetails': {
'cvss': [
{
'baseScore': 7.5,
'findingArn': 'arn:aws:test789',
'firstObservedAt': datetime(2022, 5, 4, 16, 23, 3, 692000),
'inspectorScore': 7.5,
'inspectorScoreDetails': {
'adjustedCvss': {
'adjustments': [],
'cvssSource': 'NVD',
'score': 7.5,
'scoreSource': 'NVD',
'scoringVector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N',
'source': 'NVD',
'version': '3.1',
}
],
'referenceUrls': ['https://nvd.nist.gov/vuln/detail/CVE-2023-1234'],
'relatedVulnerabilities': [],
'source': 'NVD',
'sourceUrl': 'https://nvd.nist.gov/vuln/detail/CVE-2023-1234',
'vendorCreatedAt': datetime(2023, 1, 15, 10, 0),
'vendorSeverity': 'High',
'vulnerabilityId': 'CVE-2023-1234',
'vulnerablePackages': [
{
'arch': 'X86_64',
'epoch': 0,
'name': 'openssl',
'packageManager': 'OS',
'release': '1.amzn2',
'version': '1.0.2k',
}
],
},
'remediation': {'recommendation': {'text': 'Update to the latest version of OpenSSL'}},
'resources': [{
'details': {
'awsEc2Instance': {
'iamInstanceProfileArn': 'arn:aws:iam::123456789011:instance-profile/InspectorTestingRole',
'imageId': 'ami-00800800',
'ipV4Addresses': ['10.0.1.4'],
'ipV6Addresses': [],
'keyName': 'InspectorTest',
'launchedAt': datetime(2022, 5, 4, 16, 15, 41),
'platform': 'AMAZON_LINUX_2',
'subnetId': 'subnet-11203981029833100',
'type': 't2.micro',
'vpcId': 'vpc-11203981029822100',
},
},
'id': 'i-88503981029833101',
'partition': 'aws',
'region': 'us-west-2',
'tags': {},
'type': 'AWS_EC2_INSTANCE',
}],
'severity': 'HIGH',
'status': 'ACTIVE',
'title': 'CVE-2023-1234 - openssl',
'type': 'PACKAGE_VULNERABILITY',
'updatedAt': datetime(2022, 5, 4, 16, 23, 3, 692000)
}
'lastObservedAt': datetime(2022, 5, 4, 16, 23, 3, 692000),
'packageVulnerabilityDetails': {
'cvss': [
{
'baseScore': 7.5,
'scoringVector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N',
'source': 'NVD',
'version': '3.1',
},
],
'referenceUrls': ['https://nvd.nist.gov/vuln/detail/CVE-2023-1234'],
'relatedVulnerabilities': [],
'source': 'NVD',
'sourceUrl': 'https://nvd.nist.gov/vuln/detail/CVE-2023-1234',
'vendorCreatedAt': datetime(2023, 1, 15, 10, 0),
'vendorSeverity': 'High',
'vulnerabilityId': 'CVE-2023-1234',
'vulnerablePackages': [
{
'arch': 'X86_64',
'epoch': 0,
'name': 'openssl',
'packageManager': 'OS',
'release': '1.amzn2',
'version': '1.0.2k',
},
],
},
'remediation': {'recommendation': {'text': 'Update to the latest version of OpenSSL'}},
'resources': [{
'details': {
'awsEc2Instance': {
'iamInstanceProfileArn': 'arn:aws:iam::123456789011:instance-profile/InspectorTestingRole',
'imageId': 'ami-00800800',
'ipV4Addresses': ['10.0.1.4'],
'ipV6Addresses': [],
'keyName': 'InspectorTest',
'launchedAt': datetime(2022, 5, 4, 16, 15, 41),
'platform': 'AMAZON_LINUX_2',
'subnetId': 'subnet-11203981029833100',
'type': 't2.micro',
'vpcId': 'vpc-11203981029822100',
},
},
'id': 'i-88503981029833101',
'partition': 'aws',
'region': 'us-west-2',
'tags': {},
'type': 'AWS_EC2_INSTANCE',
}],
'severity': 'HIGH',
'status': 'ACTIVE',
'title': 'CVE-2023-1234 - openssl',
'type': 'PACKAGE_VULNERABILITY',
'updatedAt': datetime(2022, 5, 4, 16, 23, 3, 692000),
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_sync_inspector_ec2_package_findings(mock_get, neo4j_session):
rel_direction_right=True,
) == {
('arn:aws:test456', 'i-88503981029833100'),
('arn:aws:test789', 'i-88503981029833101')
('arn:aws:test789', 'i-88503981029833101'),
}

assert check_rels(
Expand All @@ -128,7 +128,7 @@ def test_sync_inspector_ec2_package_findings(mock_get, neo4j_session):
) == {
('arn:aws:test456', 'kernel-tools|X86_64|4.9.17|6.29.amzn1|0'),
('arn:aws:test456', 'kernel|X86_64|4.9.17|6.29.amzn1|0'),
('arn:aws:test789', 'openssl|X86_64|1.0.2k|1.amzn2|0')
('arn:aws:test789', 'openssl|X86_64|1.0.2k|1.amzn2|0'),
}

# Assert AWSAccount RESOURCE to Finding exists
Expand Down

0 comments on commit 5281e61

Please sign in to comment.