Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

izar
Copy link
Owner

@izar izar commented Oct 24, 2023

Watching out for the "invalid" Element created when a Finding is added by hand.

@izar izar requested a review from colesmj October 24, 2023 18:39
@izar izar self-assigned this Oct 24, 2023
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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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"))
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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?

Copy link
Collaborator

@colesmj colesmj left a 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,
Copy link
Collaborator

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"))
Copy link
Collaborator

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"))
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants