diff --git a/assets/jedis-db-local.zip b/assets/jedis-db-local.zip new file mode 100644 index 0000000..ee4c893 --- /dev/null +++ b/assets/jedis-db-local.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dffa92d88ae885a385bceecfdfb877ccf25c9b72c718cfc9c9f9734f9d9076c5 +size 6727425 diff --git a/codeql-jedis/README.org b/codeql-jedis/README.org new file mode 100644 index 0000000..e5e84ce --- /dev/null +++ b/codeql-jedis/README.org @@ -0,0 +1,51 @@ +* Jedis Codeql Setup + - fork at https://github.com/hohn/jedis + - github db build: enable code scanning, advanced config + - only java-kotlin, build-mode: none. + - creates https://github.com/hohn/jedis/blob/master/.github/workflows/codeql.yml + - action run at https://github.com/hohn/jedis/actions/workflows/codeql.yml + - db download + #+BEGIN_SRC sh + # list dbs + curl -H "Authorization: token $GITHUB_TOKEN" \ + https://api.github.com/repos/hohn/jedis/code-scanning/analyses + + + # Get DB via curl + cd ~/work-gh/codeql-lab/assets + curl -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/zip" \ + -L \ + https://api.github.com/repos/hohn/jedis/code-scanning/codeql/databases/java \ + -o jedis-database-gh.zip + #+END_SRC + - db at ~/work-gh/codeql-lab/assets/jedis-database-gh.zip + - local db build: + #+BEGIN_SRC sh + cd ~/work-gh/codeql-lab/ + + # Add the submodule + git submodule add https://github.com/hohn/jedis extern/jedis + + # Initialize and clone the submodule + git submodule update --init --recursive + + + # Build directly once to resolve any errors + cd ~/work-gh/codeql-lab/extern/jedis + mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V + + # Build under codeql + # Step 1: Clean any prior Maven builds + cd ~/work-gh/codeql-lab/extern/jedis + mvn clean + + # Step 2: Run CodeQL DB creation with mvn install + cd ~/work-gh/codeql-lab + codeql database create assets/jedis-db-local \ + --overwrite \ + --language=java \ + --command="mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V" \ + --source-root=extern/jedis + #+END_SRC + diff --git a/codeql-jedis/codeql-pack.lock.yml b/codeql-jedis/codeql-pack.lock.yml new file mode 100644 index 0000000..5300427 --- /dev/null +++ b/codeql-jedis/codeql-pack.lock.yml @@ -0,0 +1,4 @@ +--- +lockVersion: 1.0.0 +dependencies: {} +compiled: false diff --git a/codeql-jedis/example.ql b/codeql-jedis/example.ql new file mode 100644 index 0000000..2631f65 --- /dev/null +++ b/codeql-jedis/example.ql @@ -0,0 +1,12 @@ +/** + * @name Empty block + * @kind problem + * @problem.severity warning + * @id java/example/empty-block + */ + +import java + +from BlockStmt b +where b.getNumStmt() = 0 +select b, "This is an empty block." diff --git a/codeql-jedis/qlpack.yml b/codeql-jedis/qlpack.yml new file mode 100644 index 0000000..be1b024 --- /dev/null +++ b/codeql-jedis/qlpack.yml @@ -0,0 +1,6 @@ +name: codeql-jedis/codeql-extra-queries-java +version: 0.0.0 +dependencies: + # This uses the latest version of the codeql/java-all library. + # You may want to change to a more precise semver string. + codeql/java-all: "*"