Skip to content

C++: Extend the GetsFunction and SystemFunction models.#3694

Merged
jbj merged 5 commits into
github:masterfrom
geoffw0:models
Jun 23, 2020
Merged

C++: Extend the GetsFunction and SystemFunction models.#3694
jbj merged 5 commits into
github:masterfrom
geoffw0:models

Conversation

@geoffw0
Copy link
Copy Markdown
Contributor

@geoffw0 geoffw0 commented Jun 11, 2020

I was hoping one of these would fix an issue I was looking at. They didn't. But the improvements are worth keeping anyway.

@geoffw0 geoffw0 added the C++ label Jun 11, 2020
@geoffw0 geoffw0 requested a review from a team as a code owner June 11, 2020 18:00
Comment thread cpp/ql/src/semmle/code/cpp/security/CommandExecution.qll
jbj
jbj previously approved these changes Jun 15, 2020
Copy link
Copy Markdown
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I took this uncontroversial PR as an opportunity to advertise a new QL language feature.


override predicate interestingArg(int arg) { arg = 0 }

override predicate hasArrayWithNullTerminator(int bufParam) { bufParam = 0 or bufParam = 1 }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's of course a matter of preference, but this disjunction can also be written as bufParam = [0, 1] (since about a month ago). Apart from saving bytes, it might make the meaning of the code jump of the screen faster because the reader doesn't have to read the words to see that bufParam is used twice and that it's an or rather than an and.

Also below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I suspect this will be most valuable when there are more than two cases (MagicConstants.qll!), and I shall look out for opportunities to use it in future. We could also update the entire models library, but I'm not in a rush to.

Comment thread cpp/ql/src/semmle/code/cpp/security/CommandExecution.qll
@jbj
Copy link
Copy Markdown
Contributor

jbj commented Jun 22, 2020

Also, the tests failed.

@geoffw0
Copy link
Copy Markdown
Contributor Author

geoffw0 commented Jun 22, 2020

I assume we're not worried about the (new, experimental?) code scanning checks at this stage, all other tests are now passing.

@jbj jbj merged commit 3747bd9 into github:master Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants