From c15e28efe65f2771a746bb914bc781b998c66e4f Mon Sep 17 00:00:00 2001 From: Dan Shanahan Date: Mon, 21 Mar 2022 10:08:23 -0700 Subject: [PATCH 1/3] enabling code-scanning --- .github/workflows/codeql-analysis.yml | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000000..cfa4ce6cd682 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,70 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '25 18 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'javascript', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 68f9a9bf4dad3db8873f4cb14c4a11e0f0501ffa Mon Sep 17 00:00:00 2001 From: Dan Shanahan Date: Mon, 21 Mar 2022 10:09:03 -0700 Subject: [PATCH 2/3] removing unused workflow --- .github/workflows/devtools_check_repro.yml | 205 --------------------- 1 file changed, 205 deletions(-) delete mode 100644 .github/workflows/devtools_check_repro.yml diff --git a/.github/workflows/devtools_check_repro.yml b/.github/workflows/devtools_check_repro.yml deleted file mode 100644 index e0335e905939..000000000000 --- a/.github/workflows/devtools_check_repro.yml +++ /dev/null @@ -1,205 +0,0 @@ -name: DevTools Check for bug repro -on: - issues: - types: [opened, edited] - issue_comment: - types: [created, edited] - -jobs: - check-repro: - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v3 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const URL_REGEXP = /### Website or app[\r\n]+([^#]+)###/m; - const REPRO_STEPS_REGEXP = /### Repro steps[\r\n]+([^#]+)###/m; - const LABEL_NEEDS_MORE_INFORMATION = "Resolution: Needs More Information"; - const LABEL_UNCONFIRMED = "Status: Unconfirmed"; - - function debug(...args) { - core.info(args.map(JSON.stringify).join(' ')); - } - - if (context.payload.comment) { - debug('Ignoring comment update.'); - return; - } - - const user = context.payload.sender.login; - const issue = context.payload.issue; - const body = issue.body; - - const urlMatch = body.match(URL_REGEXP); - const reproStepsMatch = body.match(REPRO_STEPS_REGEXP); - - const url = urlMatch !== null ? urlMatch[1].trim() : null; - const reproSteps = reproStepsMatch !== null ? reproStepsMatch[1].trim() : null; - - if (!url || !reproSteps) { - debug('This issue is not a DevTools bug report.'); - return; - } - - debug(`found URL "${url}"`); - debug(`found repro steps "${reproSteps}"`); - - async function createComment(comment) { - // Format - comment = comment - .split("\n") - .map((line) => line.trim()) - .join("\n") - .trim(); - - await github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: comment, - }); - } - - async function getGitHubActionComments() { - debug(`Loading existing comments...`); - - const comments = await github.issues.listComments({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - }); - - return comments.data.filter(comment => { - debug(`comment by user: "${comment.user.login}"`); - return comment.user.login === 'github-actions[bot]'; - }); - } - - async function getIssueLabels() { - const issues = await github.issues.listLabelsOnIssue({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - }); - - return issues.data; - } - - async function updateIssue(state, assignees = []) { - await github.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state, - assignees, - }); - } - - async function closeWithComment(comment) { - if (issue.state !== 'open') { - debug(`Issue is not open`); - return; - } - - const labels = await getIssueLabels(); - const label = labels.find(label => label.name === LABEL_UNCONFIRMED); - if (!label) { - debug(`Issue was not opened via DevTools bug report template`); - return; - } - - const comments = await getGitHubActionComments(); - if (comments.length > 0) { - debug(`Already commented on issue; won't comment again`); - return; - } - - debug(`Missing required information`); - - await github.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: [LABEL_NEEDS_MORE_INFORMATION], - }); - - await createComment(comment); - await updateIssue('closed', [user]); - } - - async function openWithComment(comment) { - if (issue.state !== 'closed') { - debug(`Issue is already open`); - return; - } - - const labels = await getIssueLabels(); - const label = labels.find(label => label.name === LABEL_NEEDS_MORE_INFORMATION); - if (!label) { - debug(`Issue was not tagged as needs information`); - return; - } - - const comments = await getGitHubActionComments(); - if (comments.length === 0) { - debug(`Issue was closed by someone else; won't reopen`); - return; - } - - debug(`Re-opening closed issue`); - - await github.issues.removeLabel({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - name: LABEL_NEEDS_MORE_INFORMATION, - }); - - await createComment(comment); - await updateIssue('open'); - } - - const PROBABLY_NOT_A_URL_REGEX = /(^Chrome$|^Firefox$| Website)/i; - - const COMMENT_HEADER = ` - @${user}: We're sorry you've seen this error. â¤ī¸ - `.trim(); - - const COMMENT_FOOTER = ` - Please help us by providing a link to a CodeSandbox (https://codesandbox.io/s/new), a repository on GitHub, or a minimal code example that reproduces the problem. (Screenshots or videos can also be helpful if they help provide context on how to repro the bug.) - - Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve - - Issues without repros are automatically closed but we will re-open if you update with repro info. - `.trim(); - - if (url.includes("localhost")) { - closeWithComment(` - ${COMMENT_HEADER} - - Unfortunately the URL you provided ("localhost") is not publicly accessible. (This means that we will not be able to reproduce the problem you're reporting.) - - ${COMMENT_FOOTER} - `); - } else if (url.length < 10 || url.match(PROBABLY_NOT_A_URL_REGEX)) { - closeWithComment(` - ${COMMENT_HEADER} - - It looks like you forgot to specify a valid URL. (This means that we will not be able to reproduce the problem you're reporting.) - - ${COMMENT_FOOTER} - `); - } else if (reproSteps.length < 25) { - closeWithComment(` - ${COMMENT_HEADER} - - Unfortunately, it doesn't look like this issue has enough info for one of us to reproduce and fix it though. - - ${COMMENT_FOOTER} - `); - } else { - openWithComment(` - Thank you for providing repro steps! Re-opening issue now for triage. - `); - } From 5102d597eed7f09c7475b098ac1dc83724b69932 Mon Sep 17 00:00:00 2001 From: Dan Shanahan Date: Mon, 21 Mar 2022 10:34:22 -0700 Subject: [PATCH 3/3] remove cpp and python --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cfa4ce6cd682..0cf592458827 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp', 'javascript', 'python' ] + language: ['javascript' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://git.io/codeql-language-support