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: init at 2.0.0 #75524

Merged
merged 1 commit into from Dec 31, 2019
Merged

codeql: init at 2.0.0 #75524

merged 1 commit into from Dec 31, 2019

Conversation

@jollheef
Copy link
Member

@jollheef jollheef commented Dec 11, 2019

Motivation for this change

Adds codeql ― semantic code analysis engine.

https://securitylab.github.com/tools/codeql

https://semmle.com/codeql

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@jollheef jollheef force-pushed the jollheef:codeql branch from ea212cd to f7d7980 Dec 13, 2019
@Lassulus
Copy link
Contributor

@Lassulus Lassulus commented Dec 23, 2019

I can't figure out how to use it. I tried this:

[nix-shell:~/src/autowifi]$ codeql database create test --language=python
Initializing database at /home/lass/src/autowifi/test.
Running command [/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/autobuild.sh] in /home/lass/src/autowifi.
[2019-12-23 12:02:33] [build-err] Traceback (most recent call last):
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/index.py", line 15, in <module>
[2019-12-23 12:02:33] [build-err]     import index
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/index.py", line 13, in <module>
[2019-12-23 12:02:33] [build-err]     sys.path = [ zippath ] + sys.path
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/install.py", line 10, in <module>
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/auto_install.py", line 8, in <module>
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/semmle/requirements.py", line 2, in <module>
[2019-12-23 12:02:33] [build-err] ModuleNotFoundError: No module named 'packaging'
[2019-12-23 12:02:33] [ERROR] Spawned process exited abnormally (code 1; tried to run: [/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/autobuild.sh])
A fatal error occurred: Exit status 1 from command [/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/autobuild.sh]
@jollheef
Copy link
Member Author

@jollheef jollheef commented Dec 26, 2019

I can't figure out how to use it. I tried this:

[nix-shell:~/src/autowifi]$ codeql database create test --language=python
Initializing database at /home/lass/src/autowifi/test.
Running command [/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/autobuild.sh] in /home/lass/src/autowifi.
[2019-12-23 12:02:33] [build-err] Traceback (most recent call last):
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/index.py", line 15, in <module>
[2019-12-23 12:02:33] [build-err]     import index
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/index.py", line 13, in <module>
[2019-12-23 12:02:33] [build-err]     sys.path = [ zippath ] + sys.path
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/install.py", line 10, in <module>
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/auto_install.py", line 8, in <module>
[2019-12-23 12:02:33] [build-err]   File "/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/pybuild.zip/semmle/requirements.py", line 2, in <module>
[2019-12-23 12:02:33] [build-err] ModuleNotFoundError: No module named 'packaging'
[2019-12-23 12:02:33] [ERROR] Spawned process exited abnormally (code 1; tried to run: [/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/autobuild.sh])
A fatal error occurred: Exit status 1 from command [/nix/store/ar98b4p2428ihjnxwafkinswxbbc33wv-codeql-2.0.0/codeql/python/tools/autobuild.sh]

Error is related to the build process of your project, not codeql itself.

Here is a minimal example of use for Python:

user@local ~ $ cd $(mktemp -d)                                                                                                                                                      ~
user@local /tmp/tmp.jGgMk8t0AM $ cat > main.py
import os

print("Hello, World!")
user@local /tmp/tmp.jGgMk8t0AM $ codeql database create test --language=python
...
Successfully created database at /tmp/tmp.jGgMk8t0AM/test.
user@local /tmp/tmp.jGgMk8t0AM $ codeql database analyze test --format=csv --output=results.csv ~/src/github.com/Semmle/ql/python/ql/src/Imports/UnusedImport.ql
Running queries.
...
Shutting down query evaluator.
Interpreting results.
user@local /tmp/tmp.jGgMk8t0AM $ cat results.csv
"Unused import","Import is not required as it is not used","recommendation","Import of 'os' is not used.","/main.py","1","1","1","9"
Copy link
Contributor

@Lassulus Lassulus left a comment

tested with nix-review

@Lassulus Lassulus merged commit dad53fa into NixOS:master Dec 31, 2019
15 checks passed
15 checks passed
codeql on aarch64-linux No attempt
Details
codeql on x86_64-linux No attempt
Details
Evaluation Performance Report Evaluator Performance Report
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A darwin-tested
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release-combined.nix -A tested
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
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

3 participants
You can’t perform that action at this time.