From 1276c41e833c05e488aa4c400273f642993f098b Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Tue, 26 Apr 2022 09:49:37 -0700 Subject: [PATCH] codeql-go merge prep: integrate go/ into codeql --- .codeqlmanifest.json | 2 ++ .gitattributes | 9 +++++ .../problem-matchers/codeql-query-format.json | 0 .../problem-matchers/codeql-syntax-check.json | 0 .../problem-matchers/codeql-test-run.json | 0 .../problem-matchers/make.json | 0 .../workflows/go-tests.yml | 30 ++++++++++++----- .github/workflows/ql-for-ql-build.yml | 2 +- .gitignore | 13 ++++++++ .lgtm.yml | 4 +++ CODEOWNERS | 1 + go/.codeqlmanifest.json | 20 ----------- go/.devcontainer/devcontainer.json | 10 ------ go/.gitattributes | 6 ---- go/.github/codeql/codeql-config.yml | 4 --- go/.github/workflows/check-change-note.yml | 33 ------------------- go/.gitignore | 28 ---------------- go/.lgtm.yml | 5 --- go/CODEOWNERS | 1 - 19 files changed, 52 insertions(+), 116 deletions(-) rename {go/.github => .github}/problem-matchers/codeql-query-format.json (100%) rename {go/.github => .github}/problem-matchers/codeql-syntax-check.json (100%) rename {go/.github => .github}/problem-matchers/codeql-test-run.json (100%) rename {go/.github => .github}/problem-matchers/make.json (100%) rename go/.github/workflows/codeqltest.yml => .github/workflows/go-tests.yml (87%) delete mode 100644 go/.codeqlmanifest.json delete mode 100644 go/.devcontainer/devcontainer.json delete mode 100644 go/.gitattributes delete mode 100644 go/.github/codeql/codeql-config.yml delete mode 100644 go/.github/workflows/check-change-note.yml delete mode 100644 go/.gitignore delete mode 100644 go/.lgtm.yml delete mode 100644 go/CODEOWNERS diff --git a/.codeqlmanifest.json b/.codeqlmanifest.json index 24e20e77278f..9f8e5ddfd819 100644 --- a/.codeqlmanifest.json +++ b/.codeqlmanifest.json @@ -6,6 +6,8 @@ "*/ql/examples/qlpack.yml", "*/ql/consistency-queries/qlpack.yml", "cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle/tainted/qlpack.yml", + "go/ql/config/legacy-support/qlpack.yml", + "go/build/codeql-extractor-go/codeql-extractor.yml", "javascript/ql/experimental/adaptivethreatmodeling/lib/qlpack.yml", "javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/qlpack.yml", "javascript/ql/experimental/adaptivethreatmodeling/src/qlpack.yml", diff --git a/.gitattributes b/.gitattributes index 5953177325f8..352b2eafe4b8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -39,6 +39,7 @@ *.py text *.lua text *.expected text +*.go text # Explicitly set a bunch of known extensions to binary, because Git < 2.10 will treat # `* text=auto eol=lf` as `* text eol=lf` @@ -52,6 +53,14 @@ java/ql/test/stubs/**/*.java linguist-generated=true java/ql/test/experimental/stubs/**/*.java linguist-generated=true +# Force git not to modify line endings for go or html files under the go/ql directory +go/ql/**/*.go -text +go/ql/**/*.html -text +# Force git not to modify line endings for go dbschemes +go/*.dbscheme -text +# Preserve unusual line ending from codeql-go merge +go/extractor/opencsv/CSVReader.java -text + # For some languages, upgrade script testing references really old dbscheme # files from legacy upgrades that have CRLF line endings. Since upgrade # resolution relies on object hashes, we must suppress line ending conversion diff --git a/go/.github/problem-matchers/codeql-query-format.json b/.github/problem-matchers/codeql-query-format.json similarity index 100% rename from go/.github/problem-matchers/codeql-query-format.json rename to .github/problem-matchers/codeql-query-format.json diff --git a/go/.github/problem-matchers/codeql-syntax-check.json b/.github/problem-matchers/codeql-syntax-check.json similarity index 100% rename from go/.github/problem-matchers/codeql-syntax-check.json rename to .github/problem-matchers/codeql-syntax-check.json diff --git a/go/.github/problem-matchers/codeql-test-run.json b/.github/problem-matchers/codeql-test-run.json similarity index 100% rename from go/.github/problem-matchers/codeql-test-run.json rename to .github/problem-matchers/codeql-test-run.json diff --git a/go/.github/problem-matchers/make.json b/.github/problem-matchers/make.json similarity index 100% rename from go/.github/problem-matchers/make.json rename to .github/problem-matchers/make.json diff --git a/go/.github/workflows/codeqltest.yml b/.github/workflows/go-tests.yml similarity index 87% rename from go/.github/workflows/codeqltest.yml rename to .github/workflows/go-tests.yml index 54e2e4d0a71d..3ad015808216 100644 --- a/go/.github/workflows/codeqltest.yml +++ b/.github/workflows/go-tests.yml @@ -1,4 +1,4 @@ -name: CodeQL tests +name: "Go: Run Tests" on: [pull_request] jobs: @@ -38,22 +38,30 @@ jobs: run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;' - name: Build - run: env PATH=$PATH:$HOME/codeql make + run: | + cd go + env PATH=$PATH:$HOME/codeql make - name: Check that all QL and Go code is autoformatted - run: env PATH=$PATH:$HOME/codeql make check-formatting + run: | + cd go + env PATH=$PATH:$HOME/codeql make check-formatting - name: Compile qhelp files to markdown - run: env PATH=$PATH:$HOME/codeql QHELP_OUT_DIR=qhelp-out make qhelp-to-markdown + run: | + cd go + env PATH=$PATH:$HOME/codeql QHELP_OUT_DIR=qhelp-out make qhelp-to-markdown - name: Upload qhelp markdown uses: actions/upload-artifact@v2 with: name: qhelp-markdown - path: qhelp-out/**/*.md + path: go/qhelp-out/**/*.md - name: Test - run: env PATH=$PATH:$HOME/codeql make test + run: | + cd go + env PATH=$PATH:$HOME/codeql make test test-mac: name: Test MacOS @@ -90,10 +98,14 @@ jobs: run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;' - name: Build - run: env PATH=$PATH:$HOME/codeql make + run: | + cd go + env PATH=$PATH:$HOME/codeql make - name: Test - run: env PATH=$PATH:$HOME/codeql make test + run: | + cd go + env PATH=$PATH:$HOME/codeql make test test-win: name: Test Windows @@ -135,9 +147,11 @@ jobs: - name: Build run: | $Env:Path += ";$HOME\codeql" + cd go make - name: Test run: | $Env:Path += ";$HOME\codeql" + cd go make test diff --git a/.github/workflows/ql-for-ql-build.yml b/.github/workflows/ql-for-ql-build.yml index 84d0e2af101d..6b4f6a0abeea 100644 --- a/.github/workflows/ql-for-ql-build.yml +++ b/.github/workflows/ql-for-ql-build.yml @@ -140,7 +140,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - folder: [cpp, csharp, java, javascript, python, ql, ruby, swift] + folder: [cpp, csharp, java, javascript, python, ql, ruby, swift, go] needs: - package diff --git a/.gitignore b/.gitignore index 9dd2effe9510..fd9e5b6a07ef 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ # qltest projects and artifacts */ql/test/**/*.testproj */ql/test/**/*.actual +*/ql/test/**/go.sum # Visual studio temporaries, except a file used by QL4VS .vs/* @@ -42,3 +43,15 @@ csharp/extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json # CLion project files /.clwb + +# Go build artifacts +go/build/* + +# Go binaries +go/tools/bin +go/tools/linux64 +go/tools/osx64 +go/tools/win64 +go/tools/tokenizer.jar +go/main + diff --git a/.lgtm.yml b/.lgtm.yml index ca0d8fa4eebe..b544d59f5209 100755 --- a/.lgtm.yml +++ b/.lgtm.yml @@ -6,6 +6,7 @@ path_classifiers: test: - csharp/ql/src - csharp/ql/test + - go/ql/test - javascript/extractor/parser-tests - javascript/extractor/tests - javascript/ql/src @@ -13,6 +14,9 @@ path_classifiers: - python/ql/src - python/ql/test + example: + - go/ql/src + queries: - include: "*" diff --git a/CODEOWNERS b/CODEOWNERS index 5ee67c52fbc7..433d9080327c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,5 +1,6 @@ /cpp/ @github/codeql-c-analysis /csharp/ @github/codeql-csharp +/go/ @github/codeql-go /java/ @github/codeql-java /javascript/ @github/codeql-javascript /python/ @github/codeql-python diff --git a/go/.codeqlmanifest.json b/go/.codeqlmanifest.json deleted file mode 100644 index c6df74dd3b5e..000000000000 --- a/go/.codeqlmanifest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "provide": [ - "ql/src/qlpack.yml", - "ql/lib/qlpack.yml", - "ql/examples/qlpack.yml", - "ql/test/qlpack.yml", - "ql/config/legacy-support/qlpack.yml", - "build/codeql-extractor-go/codeql-extractor.yml" - ], - "ignore": [ - "the-extractor-which-needs-to-be-built" - ], - "versionPolicies": { - "default": { - "requireChangeNotes": true, - "committedPrereleaseSuffix": "dev", - "committedVersion": "nextPatchRelease" - } - } -} diff --git a/go/.devcontainer/devcontainer.json b/go/.devcontainer/devcontainer.json deleted file mode 100644 index 973a584acfa9..000000000000 --- a/go/.devcontainer/devcontainer.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extensions": [ - "github.vscode-codeql", - "slevesque.vscode-zipexplorer" - ], - "settings": { - "codeQL.runningQueries.memory": 2048, - "codeQL.runningQueries.debug": true - } -} diff --git a/go/.gitattributes b/go/.gitattributes deleted file mode 100644 index fd2c3bc60654..000000000000 --- a/go/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -# Force git not to modify line endings for go or html files under the ql directory -ql/**/*.go -text -ql/**/*.html -text - -# Force git not to modify line endings for dbschemes -*.dbscheme -text diff --git a/go/.github/codeql/codeql-config.yml b/go/.github/codeql/codeql-config.yml deleted file mode 100644 index 4f21e2ef6392..000000000000 --- a/go/.github/codeql/codeql-config.yml +++ /dev/null @@ -1,4 +0,0 @@ -name: "CodeQL config" - -queries: - - uses: security-and-quality diff --git a/go/.github/workflows/check-change-note.yml b/go/.github/workflows/check-change-note.yml deleted file mode 100644 index d0467abb7c80..000000000000 --- a/go/.github/workflows/check-change-note.yml +++ /dev/null @@ -1,33 +0,0 @@ -on: - pull_request_target: - types: [labeled, unlabeled, opened, synchronize, reopened, ready_for_review] - paths: - - "ql/src/**/*.ql" - - "ql/src/**/*.qll" - - "!**/experimental/**" - -jobs: - check-change-note: - runs-on: ubuntu-latest - steps: - - name: Check if change note file is present - uses: dorny/paths-filter@7c0f15b688b020e95e00f15c61299b022f08ca95 # v2.8.0 - id: paths_filter - with: - filters: | - change_note: - - '**/change-notes/*.md' - - name: Get PR labels - id: pr-labels - uses: joerick/pr-labels-action@0a4cc4ee0ab557ec0b1ae1157fa6fa7f9f4c494b # v1.0.6 - - name: Fail if change note is missing - uses: actions/github-script@v3 - if: | - github.event.pull_request.draft == false && - steps.paths_filter.outputs.change_note == 'false' && - !contains(steps.pr-labels.outputs.labels, ' no-change-note-required ') - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - core.setFailed('No change note found.' + - ' Either add one, or add the `no-change-note-required` label.') diff --git a/go/.gitignore b/go/.gitignore deleted file mode 100644 index 4fc12cb65987..000000000000 --- a/go/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -# editor and OS artifacts -*~ -.DS_STORE - -# query compilation caches -.cache - -# build artifacts -build/* - -# qltest projects and artifacts -ql/test/**/*.testproj -ql/test/**/*.actual -ql/test/**/go.sum - -# Java class files -**/*.class - -# binaries -tools/bin -tools/linux64 -tools/osx64 -tools/win64 -tools/tokenizer.jar -main - -# QL pack output directories -.codeql \ No newline at end of file diff --git a/go/.lgtm.yml b/go/.lgtm.yml deleted file mode 100644 index ec6d8765a2ec..000000000000 --- a/go/.lgtm.yml +++ /dev/null @@ -1,5 +0,0 @@ -path_classifiers: - test: - - ql/test - example: - - ql/src diff --git a/go/CODEOWNERS b/go/CODEOWNERS deleted file mode 100644 index d076d9576d41..000000000000 --- a/go/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @github/codeql-go