-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: model os path file accesses #6741
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
Python: model os path file accesses #6741
Conversation
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.
There are a few more functions that could reveal information about the file system, by telling the last modification time of a file, e.g.
getmtime
. This will raise an error if the file does not exist, so could also reveal the existence of files depending on the applications error handling. These are currently not included.
Can we please model these as well? they fit the FileSystemAccess
concept as far as I can tell.
on non-existing files.
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
There was already a taint-step for |
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.
a few minor things
private string pathComputation() { | ||
result in [ | ||
"abspath", "basename", "commonpath", "dirname", "expanduser", "expandvars", "join", | ||
"normcase", "normpath", "realpath", "relpath", "split" | ||
] |
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.
private string pathComputation() { | |
result in [ | |
"abspath", "basename", "commonpath", "dirname", "expanduser", "expandvars", "join", | |
"normcase", "normpath", "realpath", "relpath", "split" | |
] | |
private string pathComputation() { | |
result in [ | |
"abspath", "basename", "commonpath", "commonprefix", "dirname", "expanduser", "expandvars", "join", | |
"normcase", "normpath", "realpath", "relpath", "split", "splitdrive", "splitext" | |
] |
or was there a reason not to add commonprefix
? I'm wondering if you did not include it since it might be used as a form of sanitizer? -- I don't feel doubt about splitdrive
and splitext
should have taint-steps
NIT: Since this predicate is only used once (in the char-pred of OsPathComputation
), could we please inline it there?
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.
The reasons for not including these are given in the list "Functions that need summaries". These functions all do not map tainted input to tainted output but rather map some content to some content.
// Functions that need summaries: | ||
// - os.path.commonpath(paths): takes a sequence | ||
// - os.path.commonprefix(list): takes a list argument | ||
// - os.path.splitdrive: retunrs a tuple | ||
// - os.path.splittext: returns a tuple |
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 list is incomplete (for example, missing split
). Since all our current taint-modeling would need proper flow-summaries in the future, I would suggest we remove this, and deal with it once we remodel things. it just seems a bit too brittle to my liking 😐
// Functions that need summaries: | |
// - os.path.commonpath(paths): takes a sequence | |
// - os.path.commonprefix(list): takes a list argument | |
// - os.path.splitdrive: retunrs a tuple | |
// - os.path.splittext: returns a tuple |
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.
LGTM 👍
This PR includes a number of functions in
os.path
into the conceptFileSystemAccess
. These all test for the existence of files in some way.There are a few more functions that could reveal information about the file system, by telling the last modification time of a file, e.g.
getmtime
. This will raise an error if the file does not exist, so could also reveal the existence of files depending on the applications error handling. These are currently not included.