Conversation
| "onDuplicates": "Action.NO_ACTION", | ||
| "threatsExcluded": [], | ||
| "threatsFile": "pytm/threatlib/threats.json" | ||
| "threatsFile": "{'pytm/threatlib/threats.json'}" |
There was a problem hiding this comment.
Why is the output a string and not a list of strings?
There was a problem hiding this comment.
that's what varStrings with only one value put out...
There was a problem hiding this comment.
in the immortal words of just about everybody..."works for me"!
There was a problem hiding this comment.
Ok I had a quick look and the issue is that the default to_serializable is used.
Lines 2015 to 2018 in 9dc0f1f
This is just the same as
json.dumps(str(set(["./a.json"])))The issue is created by
Line 2023 in 9dc0f1f
Because of this check for not nested in serialize().
Line 2064 in 9dc0f1f
Lines 2035 to 2070 in 9dc0f1f
This whole serialize function is a bit overloaded with special handling of member variables and might require a rewrite.
All the checks seem to be for specific classes which are all handle in the same function.
Also why is there the check for nested?
This is basically equivalent to checking if the class is TM.
A quick fix would be something like if instance(obj, TM) and i == "threatsFile" but oh boy that is not nice.
Should this be a new issue?
There was a problem hiding this comment.
sounds like something to be addressed. @nineinchnick , you there?
There was a problem hiding this comment.
There appears to be only 1 check for nested. If nested is true, the behavior seems to be potentially undefined (if the code reaches the not nested elif).
There was a problem hiding this comment.
Yes. I started to rewrite the code see #268, but it is difficult to understand what the intention here was.
It seems that the default is result[i.lstrip("_")] = value and the cases above only change the value of value.
So setting nested = True means that value will not be touched, except it is a Element, Data, or Threat. Or the name of the member is in ("levels", "sourceFiles", "assumptions").
The last one seems to be a fix for a specific class.
| [--exclude EXCLUDE] [--seq] [--list] [--describe DESCRIBE] | ||
| [--list-elements] [--json JSON] [--levels LEVELS [LEVELS ...]] | ||
| [--stale_days STALE_DAYS] | ||
| usage: tm.py [-h] [--sqldump SQLDUMP] [--debug] [--dfd] [--report REPORT] [--exclude EXCLUDE] [--seq] [--list] [--colormap] |
There was a problem hiding this comment.
Are you adding --colormap in this PR also?
There was a problem hiding this comment.
it should be there already, it is an old one. It appears on the currently checked code on the master branch.
There was a problem hiding this comment.
oh this is the readme! let me fix that
|
|
||
| # delaying loading of threats to accomodate multiple threat files in the | ||
| # command line | ||
| if result.threat_files: |
There was a problem hiding this comment.
Why do extra work on line 791 to load the default when you can just do it here? You will always reach this line at least once, correct?
There was a problem hiding this comment.
i don't remember the details but there is a timing issue there. Something around things being used before loaded.
| "onDuplicates": "Action.NO_ACTION", | ||
| "threatsExcluded": [], | ||
| "threatsFile": "pytm/threatlib/threats.json" | ||
| "threatsFile": "{'pytm/threatlib/threats.json'}" |
There was a problem hiding this comment.
There appears to be only 1 check for nested. If nested is true, the behavior seems to be potentially undefined (if the code reaches the not nested elif).
| foo_file = f"{dir_path}/1.json" | ||
| bar_file = f"{dir_path}/2.json" | ||
| threat_files = [os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | ||
| + "/pytm/threatlib/threats.json", foo_file, bar_file] |
There was a problem hiding this comment.
Do you have a test for when the default is not included in threatsfile?
There was a problem hiding this comment.
Hm. No. Gotta do one, you're right.
|
Hi there! I'd love to see this feature get accepted and ready for use downstream. My understanding is that the following is what's holding it up:
Anything else? I can at least push an update to the test. Would y'all prefer it directly pushed to this branch, or submitted as a separate PR to this branch? |
|
@adaFPF sorry for the long silence - work overrode life. Pushing to this branch should be ok. |
|
@izar I resolved the merge conflict on gitignore so this change can be merged. |
|
@izar , @raphaelahrens is resolution for #268 + #270 a dependency for this (263)? |
There is the issue of the wrong serialisation. But I would say #268 that this is not blocking this PR. |
Adds capability to select which threat lib to use on the command line: