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

Refine PyTorch and Polyglot modules #89

Merged
merged 17 commits into from
Jan 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More lint
suhacker1 committed Jan 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 56dadf38dc9aad1741e3e761eca91393318de67c
1 change: 1 addition & 0 deletions example/fault_injection.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

Note you may need to run `pip install pytorchfi`
"""

import pickle

import torch
18 changes: 10 additions & 8 deletions fickling/analysis.py
Original file line number Diff line number Diff line change
@@ -107,9 +107,9 @@ def __init__(
self.severity: Severity = severity
self.message: Optional[str] = message
self.analysis_name: str = analysis_name
self.trigger: Optional[
str
] = trigger # Field to store the trigger code fragment or artifact
self.trigger: Optional[str] = (
trigger # Field to store the trigger code fragment or artifact
)

def __lt__(self, other):
return isinstance(other, AnalysisResult) and (
@@ -296,11 +296,13 @@ def to_dict(self, verbosity: Severity = Severity.SUSPICIOUS):
analysis_message = self.to_string(verbosity)
severity_data = {
"severity": self.severity.name,
"analysis": analysis_message
if analysis_message.strip()
else "Warning: Fickling failed to detect any overtly unsafe code, but the pickle file"
"may still be unsafe."
"Do not unpickle this file if it is from an untrusted source!\n\n",
"analysis": (
analysis_message
if analysis_message.strip()
else "Warning: Fickling failed to detect any overtly unsafe code, but the pickle file"
"may still be unsafe."
"Do not unpickle this file if it is from an untrusted source!\n\n"
),
"detailed_results": self.detailed_results(),
}
return severity_data
6 changes: 2 additions & 4 deletions fickling/fickle.py
Original file line number Diff line number Diff line change
@@ -760,13 +760,11 @@ def __init__(self, initial_value: Iterable[T] = ()):

@overload
@abstractmethod
def __getitem__(self, i: int) -> T:
...
def __getitem__(self, i: int) -> T: ...

@overload
@abstractmethod
def __getitem__(self, s: slice) -> GenericSequence:
...
def __getitem__(self, s: slice) -> GenericSequence: ...

def __getitem__(self, i: int) -> T:
return self._stack[i]