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

Turn on Dependabot and CodeQL #139

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
cooljeanius marked this conversation as resolved.
Show resolved Hide resolved
82 changes: 82 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# trac-github/.github/workflows/codeql.yml: GitHub Actions codeql workflow for trac-github
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with CodeQL. Can you elaborate what the added value of this for this repository is?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so CodeQL is basically another linter / static analyzer / set of compiler warnings to help ensure future commits or PRs don't break anything. I'd feel a lot more secure about taking #138 out of draft mode if I could get a set of CI checks (such as CodeQL) set up first to verify that it'd be ok to merge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have more details than that? From what I see in the marketing material, this sounds like a closed-source third-party tool, which I cannot run locally (or only a limited version) unless I pay for a GitHub Enterprise something thingy.

Is there some way we could see what warnings CodeQL would find in this existing code base? I don't want an opinionated linter that throws a thousand warnings that nobody is ever going to fix in this code.

From a run in your fork, it seems this doesn't even work as expected, because this is still Python 2 code, but Python 2 isn't installed:

Python package installation failed: we detected this code as Python 2, but the 'python2' executable was not available. To enable automatic package installation, please install 'python2' before the 'github/codeql-action/init' step, for example by running 'sudo apt install python2' (Ubuntu 22.04). If your code is not Python 2, but actually Python 3, please file a bug report at https://github.com/github/codeql-action/issues/new

https://github.com/cooljeanius/trac-github/actions/runs/7018282343/job/19093341421

So it seems that in its current state, this CodeQL run doesn't actually do anything.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have more details than that? From what I see in the marketing material, this sounds like a closed-source third-party tool, which I cannot run locally (or only a limited version) unless I pay for a GitHub Enterprise something thingy.

CodeQL sources are available here under an MIT license: https://github.com/github/codeql

Is there some way we could see what warnings CodeQL would find in this existing code base? I don't want an opinionated linter that throws a thousand warnings that nobody is ever going to fix in this code.

From a run in your fork, it seems this doesn't even work as expected, because this is still Python 2 code, but Python 2 isn't installed:

Python package installation failed: we detected this code as Python 2, but the 'python2' executable was not available. To enable automatic package installation, please install 'python2' before the 'github/codeql-action/init' step, for example by running 'sudo apt install python2' (Ubuntu 22.04). If your code is not Python 2, but actually Python 3, please file a bug report at https://github.com/github/codeql-action/issues/new

Ah ok, let me try that...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoting from https://github.com/github/codeql:

The CodeQL CLI (including the CodeQL engine) is hosted in a different repository and is licensed separately.

Copy link
Author

@cooljeanius cooljeanius Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, here's a new run:
https://github.com/cooljeanius/trac-github/actions/runs/7118192100/job/19380559866
It still doesn't produce any warnings, but that's good, it means that this codebase doesn't have anything worth warning about. The idea is to prevent that from changing in potential future PRs.
Here's an example of a place where CodeQL does actually warn in some Python code: https://github.com/cooljeanius/jhbuild/security/code-scanning/1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neverpanic better now?

# 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:
- master
- github-stuff
- dependabot/*
- issue-sync
pull_request:
# The branches below must be a subset of the branches above
branches:
- master
- github-stuff
- dependabot/*
- issue-sync
schedule:
- cron: '37 17 * * 3'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at:
# https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
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.

# For more details on CodeQL's query packs, refer to:
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
build
dist
htmlcov
.env.local