Repository navigation
sdk%feat(lint): add clang-{format,tidy} 20, instrument with lint_clang.py, validate against cert-{c,cpp}-coding-standards and cpp-security-and-quality suites, fetch per-platform CodeQL
#111
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bfc17f0
sdk%feat(build): add `clang-{format,tidy}` 20 to workspace with rules
kwvg ae1b971
sdk%feat(lint): add `lint_clang.py` for managing `clang-{format,tidy}`
kwvg 297d32b
sdk%feat(lint): enforce C/C++ comment style with semgrep
kwvg 944b821
sdk%lint: format C/C++ sources with `clang-format`
kwvg 40dc4a1
sdk%ci(nix): fetch per-platform CodeQL 2.27, drop `unstable` channel
kwvg ea01ede
sdk%refac(lint): move clang-tidy include and SDK helpers to `common`
kwvg 8be76e0
sdk%feat(lint): pass the builds' C/C++ standards to clang-tidy
kwvg 8bb9eeb
sdk%feat(lint): check C/C++ against SEI CERT 2016 with CodeQL
kwvg d44404e
sdk%lint: fix CERT INT32-C and ERR51-CPP in probes
kwvg 003bcdc
sdk%refac(lint): read CodeQL suppressions from per-language TOML
kwvg 901e651
sdk%lint(codeql): suppress DCL37-C, `cpp/implicit-function-declaration`
kwvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,80 @@ | ||
| # CodeQL CLI | ||
|
|
||
| { pkgs, unstable }: | ||
| { pkgs, fhs }: | ||
|
|
||
| let | ||
| version = "2.27.0"; | ||
| inherit (pkgs) lib stdenv; | ||
|
|
||
| # Fetching more recent CodeQL releases requires `unstable` and `x86_64-darwin` | ||
| # as a target is no longer supported since 26.11 (see nixos/nixpkgs#535508), | ||
| # though GitHub themselves still provide binaries that support Intel Macs so | ||
| # we rely on a pin for `x86_64-darwin` and consume from `unstable` otherwise. | ||
| pinned = pkgs.codeql.overrideAttrs (_: { | ||
| inherit version; | ||
| version = "2.27.0"; | ||
|
|
||
| src = pkgs.fetchzip { | ||
| url = "https://github.com/github/codeql-cli-binaries/releases/download/v${version}/codeql.zip"; | ||
| hash = "sha256-8WhsburnhVWvVLTNOmAwmkjwN45exmKmw7Q5elTjYiI="; | ||
| # GitHub's archive for each host, named by the directory under `tools/` that | ||
| # holds its native binaries. The universal `codeql.zip` lacks `linux-arm64`. | ||
| osx64 = { | ||
| name = "osx64"; | ||
| hash = "sha256-47H7FQy/67sZvgSTAAgXfoGKxChL1khLaLqxanHFd7c="; | ||
| }; | ||
| archives = { | ||
| "aarch64-darwin" = osx64; | ||
| "x86_64-darwin" = osx64; | ||
| "aarch64-linux" = { | ||
| name = "linux-arm64"; | ||
| hash = "sha256-PdJozYk3zs+vRH0OwIJawGrCuatVd7huzACGIViVN/0="; | ||
| }; | ||
| }); | ||
| "x86_64-linux" = { | ||
| name = "linux64"; | ||
| hash = "sha256-L87sPrfRSYfCjjZqv1V7L7diZoL+LG5HbWSMqIeZCEE="; | ||
| }; | ||
| }; | ||
|
|
||
| codeql = if pkgs.stdenv.hostPlatform.system == "x86_64-darwin" then pinned else unstable.codeql; | ||
| archive = | ||
| archives.${stdenv.hostPlatform.system} | ||
| or (throw "codeql: no archive for ${stdenv.hostPlatform.system}"); | ||
| in | ||
| { | ||
| packages = [ codeql ]; | ||
| packages = [ | ||
| (stdenv.mkDerivation { | ||
| pname = "codeql"; | ||
| inherit version; | ||
|
|
||
| src = pkgs.fetchzip { | ||
| url = "https://github.com/github/codeql-cli-binaries/releases/download/v${version}/codeql-${archive.name}.zip"; | ||
| inherit (archive) hash; | ||
| }; | ||
|
|
||
| dontConfigure = true; | ||
| dontBuild = true; | ||
| dontStrip = true; | ||
|
|
||
| # CodeQL searches the parent of its distribution for packs, so the tree | ||
| # sits in `$out/codeql` to keep that parent from being the whole store. | ||
| installPhase = '' | ||
| mkdir -p $out/{codeql,bin} | ||
| cp -R * $out/codeql/ | ||
| ${lib.optionalString stdenv.hostPlatform.isLinux '' | ||
| tools=$out/codeql/tools/${archive.name} | ||
| # The tracer preloads `libtrace.so`; `linux-arm64` names it otherwise. | ||
| [ -e $tools/libtrace.so ] || ln -s $tools/lib64trace.so $tools/libtrace.so | ||
| # The extractors find Java through the tools directory, and the | ||
| # bundled one expects an FHS loader, so nixpkgs' Java stands in. | ||
| rm -rf $tools/java | ||
| ln -s ${pkgs.jdk21} $tools/java | ||
| # The native extractors expect an FHS loader and glibc, so the CLI | ||
| # and every tool it spawns run inside `fhs-run`. | ||
| printf '#!%s\nexec %s %s "$@"\n' ${stdenv.shell} \ | ||
| ${fhs.run}/bin/fhs-run $out/codeql/codeql > $out/bin/codeql | ||
| chmod +x $out/bin/codeql | ||
| ''} | ||
| ${lib.optionalString (!stdenv.hostPlatform.isLinux) '' | ||
| ln -s $out/codeql/codeql $out/bin/ | ||
| ''} | ||
| ''; | ||
|
|
||
| meta = { | ||
| description = "Semantic code analysis engine"; | ||
| homepage = "https://codeql.github.com"; | ||
| license = lib.licenses.unfree; | ||
| platforms = lib.attrNames archives; | ||
| }; | ||
| }) | ||
| ]; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,5 +41,6 @@ let | |
| }; | ||
| in | ||
| { | ||
| inherit run; | ||
| packages = lib.optional pkgs.stdenv.hostPlatform.isLinux run; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,6 @@ | |
|
|
||
| int add(int a, int b) | ||
| { | ||
| return a + b; | ||
| int sum = 0; | ||
| return __builtin_add_overflow(a, b, &sum) ? 0 : sum; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.