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

Test codeql #6

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ FROM ubuntu:22.04 AS codeql_base
# # tzdata install needs to be non-interactive
# ENV DEBIAN_FRONTEND=noninteractive

ARG USERNAME=codeql
ARG USERNAME=root
ARG CODEQL_HOME=/usr/local/codeql-home

# create user, install/update basics and python
RUN adduser --home ${CODEQL_HOME} ${USERNAME} && \
apt-get update && \
RUN mkdir ${CODEQL_HOME}

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
software-properties-common \
Expand All @@ -30,7 +31,8 @@ RUN adduser --home ${CODEQL_HOME} ${USERNAME} && \
gcc \
apt-utils \
&& \
apt-get clean
apt-get clean \
docker-cli

# Install Go
ARG GOVER=1.21.5
Expand Down
50 changes: 27 additions & 23 deletions .devcontainer/csharp/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"name": "CodeQL-CSharp",
"build": { "dockerfile": "../Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
},
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer",
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit"
]
}
}
}
{
"name": "CodeQL-CSharp",
"build": { "dockerfile": "../Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-contrib/features/act-asdf:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"runArgs": ["--privileged"],
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer",
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit"
]
}
}
}
46 changes: 25 additions & 21 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
{
"name": "CodeQL",
"build": { "dockerfile": "Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer"
]
}
}
}
{
"name": "CodeQL",
"build": { "dockerfile": "Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-contrib/features/act-asdf:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"runArgs": ["--privileged"],
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer"
]
}
}
}
28 changes: 28 additions & 0 deletions .devcontainer/kotlin/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "CodeQL-Kotlin",
"build": { "dockerfile": "../Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-contrib/features/act-asdf:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/java:1": {},
"ghcr.io/devcontainers-extra/features/gradle-sdkman:2": {},
"ghcr.io/devcontainers-extra/features/kotlin-sdkman:2": {}
},
"runArgs": ["--privileged"],
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer"
]
}
}
}
48 changes: 26 additions & 22 deletions .devcontainer/node/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
{
"name": "CodeQL-Node",
"build": { "dockerfile": "../Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer"
]
}
}
}
{
"name": "CodeQL-Node",
"build": { "dockerfile": "../Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-contrib/features/act-asdf:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"runArgs": ["--privileged"],
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer"
]
}
}
}
48 changes: 26 additions & 22 deletions .devcontainer/python/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
{
"name": "CodeQL-Python",
"build": { "dockerfile": "../Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/python:1": {}
},
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer"
]
}
}
}
{
"name": "CodeQL-Python",
"build": { "dockerfile": "../Dockerfile" },
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers-contrib/features/act-asdf:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"runArgs": ["--privileged"],
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
"customizations": {
"extensions": [
"ms-vscode-remote.remote-containers"
],
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"github.vscode-codeql",
"MS-SarifVSCode.sarif-viewer"
]
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/codeql-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches: [ "main" ]

jobs:
analyze:
analyze-cli:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/codeql-kotlin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "CodeQL Advanced - Kotlin"

on:
pull_request:
branches: [ "main" ]
push:
branches:
- main


jobs:
analyze-kotlin:
name: Analyze Kotlin
runs-on: 'ubuntu-latest'
permissions:
actions: write
contents: read
packages: read
security-events: write

strategy:
fail-fast: false
matrix:
include:
- language: java-kotlin
build-mode: manual

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java-kotlin
queries: security-extended

- name: Build Project
shell: bash
run: |
cd kotlin-sample; gradle build --info

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"


7 changes: 3 additions & 4 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ jobs:
name: Analyze (${{ matrix.language }})
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
actions: write
contents: read
packages: read
security-events: write

strategy:
fail-fast: false
Expand Down
12 changes: 12 additions & 0 deletions kotlin-sample/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary

5 changes: 5 additions & 0 deletions kotlin-sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
52 changes: 52 additions & 0 deletions kotlin-sample/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Kotlin application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.10.2/userguide/building_java_projects.html in the Gradle documentation.
*/

plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
alias(libs.plugins.kotlin.jvm)

// Apply the application plugin to add support for building a CLI application in Java.
application
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
// Use the Kotlin JUnit 5 integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")

// Use the JUnit 5 integration.
testImplementation(libs.junit.jupiter.engine)

testRuntimeOnly("org.junit.platform:junit-platform-launcher")

// This dependency is used by the application.
implementation(libs.guava)

implementation("mysql:mysql-connector-java:8.0.33") // MySQL driver for JDBC
testImplementation(kotlin("test"))
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

application {
// Define the main class for the application.
mainClass = "org.example.AppKt"
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
Loading