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

CodeQL #12

Merged
merged 3 commits into from
Nov 21, 2023
Merged

CodeQL #12

merged 3 commits into from
Nov 21, 2023

Conversation

andyhhp
Copy link
Collaborator

@andyhhp andyhhp commented Sep 26, 2022

Several RFCs here.

  • Are we happy swapping M32=y/n for BITS=32/64 in the first place? I can fix the CodeQL bug while retaining M32= but I don't really like leaving M32= in place.
  • Do we want to run security-and-quality (i.e. everything) by default? It shows up 40 issues, most of which I think are false positives, but can probably be fixed by doing certain things in more standard ways.

@dpsmith Along with merging this, we should disable the LGTM plugin for the repo.

https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/ for full info.

@krystian-hebel
Copy link
Member

I'm all for BITS, its much clearer than M32=n.

As for CodeQL, it has all false positives from LGTM and some more, most notably it doesn't seem to understand noreturn. Also, I'd like to know what happened here https://github.com/TrenchBoot/secure-kernel-loader/security/code-scanning/31, namely where sizeof(tpm_sha1_digest) comes from and why sizeof() result isn't size_t. If we can get rid of false positives like the last one by running different set of tests I think we should do it, because I honestly don't see how we can fix that memcpy() call, it is already as standard as it can be.

On the positive side, information is presented in much more readable way than LGTM did it.

@andyhhp
Copy link
Collaborator Author

andyhhp commented Sep 27, 2022

I have a suspicion that all of this fallout stems from https://github.com/TrenchBoot/secure-kernel-loader/security/code-scanning/14 and the likes of https://github.com/TrenchBoot/secure-kernel-loader/security/code-scanning/17 where CodeQL is clearly getting confused as to what a size_t is, and/or failing to spot the declarations of the string functions.

My best guess is that it's either something about not parsing -include properly to the compiler or getting confused given the magic in include/string.h. All of the incompatible argument issues are complaining about integer promotion.

The two "real" issues are the high severity ones. https://github.com/TrenchBoot/secure-kernel-loader/security/code-scanning/18 is a false positive, due to the identified code being unreachable in all cases where mle_header isn't initialised. https://github.com/TrenchBoot/secure-kernel-loader/security/code-scanning/40 is intentional, and something a static analyser ought to flag. It probably wants a semantic code comment explaining why this case is correct.

@andyhhp
Copy link
Collaborator Author

andyhhp commented Sep 28, 2022

I've opened github/codeql#10600 for the noreturn issue, and github/codeql#10601 for the size_t issue.

@macpijan
Copy link
Member

@krystian-hebel @andyhhp

I've opened github/codeql#10600 for the noreturn issue, and github/codeql#10601 for the size_t issue.

Both of these are closed already. Did you have any more comments or suggestions on how to move forward here?

We could push this as part of the task: TrenchBoot/trenchboot-issues#19

CodeQL complains, and they're not strictly necessary.

Signed-off-by: Andrew Cooper <[email protected]>
It turns out that CodeQL gets confused with an integer 'bits' value in the
matrix, causing it to merge results.  Switch to using strings values instead.

Additionally, M32 is a very unintuitive name.  Change the build system to take
a BITS=32/64 input and parse it appropriately.  Update the build invocations
to match.

Signed-off-by: Andrew Cooper <[email protected]>
LGTM is deprecated and will cease working in Decemeber, per
https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/

Drop the LGTM badges too, as they will stop working as well.

Signed-off-by: Andrew Cooper <[email protected]>
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Copy link
Collaborator

@rossphilipson rossphilipson left a comment

Choose a reason for hiding this comment

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

Looked it over...
Reviewed-by: Ross Philipson [email protected]

Copy link
Collaborator

@dpsmith dpsmith left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Daniel P. Smith [email protected]

@andyhhp andyhhp merged commit 87150e0 into TrenchBoot:master Nov 21, 2023
33 checks passed
@andyhhp andyhhp deleted the codeql branch November 21, 2023 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants