-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Ruby: Model the posix-spawn gem #8737
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
Conversation
#8635 has some more complex logic for identifying which arguments are passed to the spawned process - possibly we should try to share some of that to get the same benefits here. |
548b530
to
fcf3967
Compare
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.
I have some nitpicks, but otherwise looks great.
exists(API::Node spawn | spawn = API::getTopLevelMember("POSIX").getMember("Spawn") | | ||
this = | ||
posixSpawnModule() | ||
.getAMethodCall(["spawn", "fspawn", "popen4", "pspawn", "system", "_pspawn", "`"]) | ||
) |
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.
You don't need the spawn
variable:
exists(API::Node spawn | spawn = API::getTopLevelMember("POSIX").getMember("Spawn") | | |
this = | |
posixSpawnModule() | |
.getAMethodCall(["spawn", "fspawn", "popen4", "pspawn", "system", "_pspawn", "`"]) | |
) | |
this = | |
posixSpawnModule() | |
.getAMethodCall(["spawn", "fspawn", "popen4", "pspawn", "system", "_pspawn", "`"]) | |
) |
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.
Ah yeah, remnant of some lazy refactoring on my part...
exists(int n, int m, DataFlow::Node otherArg | | ||
this.argument(arg, n) and | ||
this.argument(otherArg, m) and |
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.
Could be simplified to the following, witihout loss of meaning
exists(int n, int m, DataFlow::Node otherArg | | |
this.argument(arg, n) and | |
this.argument(otherArg, m) and | |
exists(DataFlow::Node otherArg | | |
this.argument(arg, _) and | |
this.argument(otherArg, _) and |
And you probably want to add and not arg = otherArg
.
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.
I also missed a not
before the exists
! Very sloppy. Should all be fixed now 🤞
) | ||
} | ||
|
||
private predicate argument(DataFlow::Node arg, int n) { |
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.
And if you take my suggestion above, then it could be simplified more by removing this n
param.
This gem exists primarily to provide methods that spawn subprocesses. We model these as SystemCommandExecutions.
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 gem exists primarily to provide methods that spawn subprocesses. We
model these as
SystemCommandExecution
s.