-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #222: fixed Findings creating spuriois Elements #223
base: master
Are you sure you want to change the base?
Conversation
class varControls(var): | ||
def __set__(self, instance, value): | ||
if not isinstance(value, Controls): | ||
raise ValueError( | ||
"expecting an Controls " | ||
"value, got a {}".format(type(value)) | ||
"expecting an Controls " "value, got a {}".format(type(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"expecting an Controls " "value, got a {}".format(type(value)) | |
"expecting an Controls value, got a {}".format(type(value)) |
@@ -661,7 +667,7 @@ def __init__( | |||
if args: | |||
element = args[0] | |||
else: | |||
element = kwargs.pop("element", Element("invalid")) | |||
element = kwargs.pop("element", Element("created from Finding")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the Element()
is used here as a default value only to avoid checking later if element is None
. If that's the case, it's better to explicitly check for it in this function, than check for a reserved name elsewhere in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In class Finding, element is set to required. If Finding can be connected to the tm rather than a specific Element, it seems this might address the problem. A dummy element is being created just to satisfy this constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Furthermore, Finding also has 2 attributes on associating with Elements:
- element - required Element object
- target - optional - string?
Maybe we need to remove one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the change made - to change the name of the dummy finding on pytm.py:670 for easier filtering later is reasonable, but I think some more conversation is needed around Finding.element vs .target and whether .element needs to be required.
if hasattr(e.source, "isEncryptedAtRest"): | ||
for d in e.data: | ||
d._safeset( | ||
"isSourceEncryptedAtRest", e.source.controls.isEncryptedAtRest | ||
"isSourceEncryptedAtRest", | ||
e.source.controls.isEncryptedAtRest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change appears to go against the convention you have for other changes in this set - from a single line _safeset() to 2-line, but here you have 3-lines. Try to be consistent.
@@ -661,7 +667,7 @@ def __init__( | |||
if args: | |||
element = args[0] | |||
else: | |||
element = kwargs.pop("element", Element("invalid")) | |||
element = kwargs.pop("element", Element("created from Finding")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In class Finding, element is set to required. If Finding can be connected to the tm rather than a specific Element, it seems this might address the problem. A dummy element is being created just to satisfy this constraint.
@@ -661,7 +667,7 @@ def __init__( | |||
if args: | |||
element = args[0] | |||
else: | |||
element = kwargs.pop("element", Element("invalid")) | |||
element = kwargs.pop("element", Element("created from Finding")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Furthermore, Finding also has 2 attributes on associating with Elements:
- element - required Element object
- target - optional - string?
Maybe we need to remove one?
Watching out for the "invalid" Element created when a Finding is added by hand.