This PR makes multiple feature additions for usability. Specifically, this PR adds a fickling import hook, global function hook, fickling.load() function, and a JSON output format for the check_safety component of the CLI. Each of these features can make it easier to integrate fickling into different codebases and tools.
This PR also updates the examples and tests to reflect these new features. Additional important changes made include:
Syncing is_likely_safe in fickle.py with check_safety in analysis.py: A new check_safety method was added to fickle.py as a wrapper with is_likely_safe being marked for deprecation.
Refactoring analysis.py: Not only was ProtoAnalysis split for simplicity, but more structure was added throughout the different analysis classes to enable the reporting of detailed results.
Adding new methods to pytorch.py: The PyTorchModelWrapper class now reports the identified file formats from the validation method.
I would especially appreciate feedback on:
Whether the hook tailored for torch.load should be included
Whether the naming throughout is consistent and appropriate
How usable the interfaces now exposed by fickling are
How useful the current state of the JSON output is
Example JSON Output ("test_unused_variables.json"):
{
"severity": "OVERTLY_MALICIOUS",
"analysis": "Call to `eval(b'[5, 6, 7, 8]')` is almost certainly evidence of a malicious pickle file\nVariable `_var0` is assigned value `eval(b'[5, 6, 7, 8]')` but unused afterward; this is suspicious and indicative of a malicious pickle file",
"detailed_results": {
"AnalysisResult": {
"OvertlyBadEval": "eval(b'[5, 6, 7, 8]')",
"UnusedVariables": [
"_var0",
"eval(b'[5, 6, 7, 8]')"
]
}
}
}
This PR makes multiple feature additions for usability. Specifically, this PR adds a fickling import hook, global function hook,
fickling.load()
function, and a JSON output format for thecheck_safety
component of the CLI. Each of these features can make it easier to integrate fickling into different codebases and tools.This PR also updates the examples and tests to reflect these new features. Additional important changes made include:
is_likely_safe
infickle.py
withcheck_safety
inanalysis.py
: A newcheck_safety
method was added tofickle.py
as a wrapper withis_likely_safe
being marked for deprecation.analysis.py
: Not only wasProtoAnalysis
split for simplicity, but more structure was added throughout the different analysis classes to enable the reporting of detailed results.pytorch.py
: ThePyTorchModelWrapper
class now reports the identified file formats from the validation method.I would especially appreciate feedback on:
torch.load
should be includedExample JSON Output ("test_unused_variables.json"):