Skip to content

Commit f5dfc0a

Browse files
twistlock: defende against compliances being null
1 parent c305890 commit f5dfc0a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

docs/content/en/open_source/contributing/how-to-write-a-parser.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ Good example:
166166
finding.cwe = data["mykey"]
167167
```
168168

169+
```python
170+
finding.cwe = data.get("mykey", 123)
171+
```
172+
173+
```python
174+
some_list = data.get("key_of_the_list") or []
175+
```
176+
177+
The finale example guards against cases where `key_of_the_list` is present, but `null`.
178+
179+
169180
### Parsing of CVSS vectors
170181

171182
Data can have `CVSS` vectors or scores. Defect Dojo use the `cvss` module provided by RedHat Security.

0 commit comments

Comments
 (0)