mirror of
https://github.com/mandiant/capa.git
synced 2025-12-23 07:28:34 -08:00
Fix KeyError when deleting nonexistent keys
`hidden_meta` saves not only the existing hidden meta keys, but also
those who don't exist with value `None`. For example:
```
{'capa/path': None, 'capa/nursery': None}
```
Deleting nonexistent keys raises a `KeyError` exception.
This commit is contained in:
@@ -590,10 +590,11 @@ class Rule(object):
|
|||||||
# save off the existing hidden meta values,
|
# save off the existing hidden meta values,
|
||||||
# emit the document,
|
# emit the document,
|
||||||
# and re-add the hidden meta.
|
# and re-add the hidden meta.
|
||||||
hidden_meta = {
|
hidden_meta = {}
|
||||||
key: meta.get(key)
|
for key in HIDDEN_META_KEYS:
|
||||||
for key in HIDDEN_META_KEYS
|
value = meta.get(key)
|
||||||
}
|
if value:
|
||||||
|
hidden_meta[key] = value
|
||||||
|
|
||||||
for key in hidden_meta.keys():
|
for key in hidden_meta.keys():
|
||||||
del meta[key]
|
del meta[key]
|
||||||
|
|||||||
Reference in New Issue
Block a user