Repository navigation
98 lines (82 loc) · 2.92 KB
/
Copy pathcodeql-analysis.yml
File metadata and controls
98 lines (82 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: "OrionFlow CodeQL"
on:
push:
paths:
- '**/*.orion'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
security-events: write
strategy:
matrix:
language: [ 'java-kotlin' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: true
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Extract file name from commit message
id: extract_file
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
FILENAME="$(printf '%s\n' "$COMMIT_MESSAGE" | head -n 1)"
echo "script=$FILENAME" >> "$GITHUB_OUTPUT"
if [ -f "$FILENAME" ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "run=false" >> "$GITHUB_OUTPUT"
echo "Error: File $FILENAME mentioned in the commit does not exist"
fi
- name: Skip if no valid Orion script
if: steps.extract_file.outputs.run == 'false'
run: echo "No valid .orion file found — skipping."
- name: Clean old generated queries
if: steps.extract_file.outputs.run == 'true'
run: rm -rf .github/codeql/queries/*
- name: Generate CodeQL queries for Spring Data MongoDB
if: steps.extract_file.outputs.run == 'true'
run: |
echo "Generating queries for ${{ steps.extract_file.outputs.script }}"
java --add-opens java.base/java.lang=ALL-UNNAMED \
-jar .github/codeql/generator.jar \
-i "${{ steps.extract_file.outputs.script }}" \
-o .github/codeql/queries \
-f mongo
- name: Commit generated queries
if: steps.extract_file.outputs.run == 'true'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: update CodeQL queries from ${{ steps.extract_file.outputs.script }}"
file_pattern: ".github/codeql/queries/**"
- name: Initialize CodeQL
if: steps.extract_file.outputs.run == 'true'
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
- name: Build StudAdvice with Maven
if: steps.extract_file.outputs.run == 'true'
run: bash ./mvnw -B compile
- name: Perform CodeQL Analysis
if: steps.extract_file.outputs.run == 'true'
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"
output: results.sarif
- name: Preserve SARIF
if: always()
uses: actions/upload-artifact@v4
with:
name: orionflow-sarif-${{ github.run_id }}
path: results.sarif/