Visitar URL original
Add query for CWE-758: Reliance on Undefined, Unspecified, or Implementation-Defined Behavior by ihsinme · Pull Request #6231 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20220303100341/https://github.com/github/codeql/pull/6231
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

Add query for CWE-758: Reliance on Undefined, Unspecified, or Implementation-Defined Behavior #6231

Merged
merged 3 commits into from Jul 15, 2021
Merged

Add query for CWE-758: Reliance on Undefined, Unspecified, or Implementation-Defined Behavior #6231

merged 3 commits into from Jul 15, 2021

Conversation

ihsinme
Copy link
Contributor

@ihsinme ihsinme commented Jul 5, 2021

Good day.
in this query I am looking for possible undefined behavior errors in expressions.
I have identified 4 main areas:

  1. dangerous use of several incremental (decremental) operations, between sequence points.
  2. using the functions of freeing resources.
  3. the use of a common argument that can change the value inside the function.
  4. the presence of a common global variable that can change its value.

search results in real software:
glennrp/libpng#378
FortressOne/fteqw-code#5
arthurodriguesbatista/tiger-compiler#1
LindaBoussetila/game_persistence#1
robertdavidgraham/masscan#586

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Hi @ihsinme, thank you for this contribution!

I've had a quick read through the code and it looks like a promising area to explore. We do have cpp/errors-when-using-bit-operations but I don't think it covers anywhere near as much stuff as your query does.

…entationDefinedBehavior.ql

Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
@ihsinme
Copy link
Contributor Author

@ihsinme ihsinme commented Jul 14, 2021

This is not the first time I notice that you find the code that you have and that is similar to my suggestions, more efficiently than me. if you could give me a couple of tips as you are looking for, I would make fewer mistakes in this direction.

@geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jul 14, 2021

When I'm looking for existing queries I generally just search the query directory (https://github.com/github/codeql/tree/main/cpp/ql/src) for one or two keywords I think might be appropriate. It isn't a flawless process.

@geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jul 14, 2021

Here's a run of the query on a fairly large collection of LGTM projects: https://lgtm.com/query/523449955668756695/

I was worried this would be a noisy query but this turns out not to be the case, results appear quite promising. 👍

Do you want me to merge this now or wait for any other changes?

@ihsinme
Copy link
Contributor Author

@ihsinme ihsinme commented Jul 15, 2021

if you think the request is mergeable.
let's merge.

Copy link
Contributor

@geoffw0 geoffw0 left a comment

LGTM.

@geoffw0 geoffw0 merged commit c4322fd into github:main Jul 15, 2021
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants