Skip to content

Commit 4935ad7

Browse files
authored
Add support for multiple patch levels (#9)
* Add support for multiple patch levels * Fix test depends * Cleanups
1 parent 7d87c9d commit 4935ad7

9 files changed

Lines changed: 70 additions & 17 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test and build
1+
name: Test
22

33
env:
44
REGISTRY: ghcr.io

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This library is part of a wider OWASP Dependency Track tool chain:
4444

4545
1. Install the requirements: `pip install -r requirements.txt`
4646
2. Start a OWASP DT instance locally (like via. Docker-Compose): https://docs.dependencytrack.org/getting-started/deploy-docker/
47-
3. Run `regenerate-api-client.sh`
47+
3. Run `regenerate-api-client.sh [patch-full.json|patch-minimal.json]`
4848
4. Check if bug https://github.com/openapi-generators/openapi-python-client/issues/1256 is still in effect
4949
5. Publish this library with the API version tag
5050

owasp_dt/models/api_key.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ class ApiKey:
2222
last_used (Union[Unset, int]): UNIX epoch timestamp in milliseconds
2323
public_id (Union[Unset, str]):
2424
key (Union[Unset, str]):
25-
legacy (Union[Unset, bool]):
2625
masked_key (Union[Unset, str]):
26+
legacy (Union[Unset, bool]):
2727
"""
2828

2929
comment: Union[Unset, str] = UNSET
3030
created: Union[Unset, int] = UNSET
3131
last_used: Union[Unset, int] = UNSET
3232
public_id: Union[Unset, str] = UNSET
3333
key: Union[Unset, str] = UNSET
34-
legacy: Union[Unset, bool] = UNSET
3534
masked_key: Union[Unset, str] = UNSET
35+
legacy: Union[Unset, bool] = UNSET
3636
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
3737

3838
def to_dict(self) -> dict[str, Any]:
@@ -46,10 +46,10 @@ def to_dict(self) -> dict[str, Any]:
4646

4747
key = self.key
4848

49-
legacy = self.legacy
50-
5149
masked_key = self.masked_key
5250

51+
legacy = self.legacy
52+
5353
field_dict: dict[str, Any] = {}
5454
field_dict.update(self.additional_properties)
5555
field_dict.update({})
@@ -63,10 +63,10 @@ def to_dict(self) -> dict[str, Any]:
6363
field_dict["publicId"] = public_id
6464
if key is not UNSET:
6565
field_dict["key"] = key
66-
if legacy is not UNSET:
67-
field_dict["legacy"] = legacy
6866
if masked_key is not UNSET:
6967
field_dict["maskedKey"] = masked_key
68+
if legacy is not UNSET:
69+
field_dict["legacy"] = legacy
7070

7171
return field_dict
7272

@@ -83,18 +83,18 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
8383

8484
key = d.pop("key", UNSET)
8585

86-
legacy = d.pop("legacy", UNSET)
87-
8886
masked_key = d.pop("maskedKey", UNSET)
8987

88+
legacy = d.pop("legacy", UNSET)
89+
9090
api_key = cls(
9191
comment=comment,
9292
created=created,
9393
last_used=last_used,
9494
public_id=public_id,
9595
key=key,
96-
legacy=legacy,
9796
masked_key=masked_key,
97+
legacy=legacy,
9898
)
9999

100100
api_key.additional_properties = d
File renamed without changes.

patch-minimal.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"components": {
3+
"schemas": {
4+
"Vulnerability": {
5+
"properties": {
6+
"findingAttribution": {
7+
"$ref": "#/components/schemas/FindingAttrib"
8+
}
9+
}
10+
},
11+
"FindingAttrib": {
12+
"type": "object",
13+
"properties": {
14+
"attributedOn": {
15+
"type": "integer",
16+
"description": "UNIX epoch timestamp in milliseconds",
17+
"format": "int64"
18+
},
19+
"analyzerIdentity": {
20+
"type": "string",
21+
"enum": [
22+
"INTERNAL_ANALYZER",
23+
"OSSINDEX_ANALYZER",
24+
"NPM_AUDIT_ANALYZER",
25+
"VULNDB_ANALYZER",
26+
"SNYK_ANALYZER",
27+
"TRIVY_ANALYZER",
28+
"NONE"
29+
]
30+
},
31+
"component": {
32+
"$ref": "#/components/schemas/Component"
33+
},
34+
"vulnerability": {
35+
"$ref": "#/components/schemas/Vulnerability"
36+
},
37+
"alternateIdentifier": {
38+
"type": "string"
39+
},
40+
"referenceUrl": {
41+
"type": "string"
42+
},
43+
"uuid": {
44+
"type": "string",
45+
"format": "uuid"
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}

regenerate-api-client.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/usr/bin/env bash
22

3+
PATCH_FILE="$1"
4+
USE_PATCH_FILE="${PATCH_FILE:-patch-full.json}"
5+
36
curl -lo openapi.json http://localhost:8081/api/openapi.json
47
#jq -s 'reduce .[] as $item ({}; . * $item)' openapi.json patch.json > schema.json
5-
jq -s '.[0] * .[1]' openapi.json patch.json > schema.json
8+
jq -s '.[0] * .[1]' openapi.json "${USE_PATCH_FILE}" > schema.json
69
jq 'del(.components.schemas.FindingAttribution)' schema.json > tmp.json
710
mv tmp.json schema.json
811
openapi-python-client generate --overwrite --path ./schema.json --meta none --config generator-config.yml

schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13355,11 +13355,11 @@
1335513355
"key": {
1335613356
"type": "string"
1335713357
},
13358-
"legacy": {
13359-
"type": "boolean"
13360-
},
1336113358
"maskedKey": {
1336213359
"type": "string"
13360+
},
13361+
"legacy": {
13362+
"type": "boolean"
1336313363
}
1336413364
}
1336513365
},

test/test_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from pathlib import Path
21
from time import sleep
32

43
import pytest
@@ -9,6 +8,7 @@
98
from owasp_dt.api.event import is_token_being_processed_1
109
from owasp_dt.models import UploadBomBody, IsTokenBeingProcessedResponse
1110

11+
1212
def test_upload_sbom(client: owasp_dt.Client):
1313
with open(test.base_dir / "files/test.sbom.xml") as sbom_file:
1414
resp = upload_bom.sync_detailed(client=client, body=UploadBomBody(

test/test_violations.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pytest
2-
from is_empty import empty
32

43
import owasp_dt
54
import test

0 commit comments

Comments
 (0)