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

Security: CI Hardening #2

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c1a6c95
Add support for GraalVM
sgammon Jun 8, 2024
e7863cd
fix: only build gvm sources on jdk11+
sgammon Jun 8, 2024
ae2ec5c
fixup!: missing conditional
sgammon Jun 8, 2024
8da6e16
fixup!: jdk8 missing classses dir
sgammon Jun 8, 2024
adf136c
test: sample/test gradle build for native image
sgammon Jun 8, 2024
a730c69
chore: ci config to run native sample
sgammon Jun 8, 2024
14d3102
fixup!: gradle properties
sgammon Jun 8, 2024
cf31c77
fix: duplicate dependencies block in gvm pom
sgammon Jun 8, 2024
8ae4edb
fix: method alignment in default feature
sgammon Jun 8, 2024
e607719
fixup!: give native image test an arg
sgammon Jun 8, 2024
c6fad3d
fix: proxy config for user code sample
sgammon Jun 8, 2024
cdd2fe9
chore: update touched libs
sgammon Jun 8, 2024
afe9e2c
chore: update remaining distlibs
sgammon Jun 8, 2024
2b6e853
fixup!: gvm ci job
sgammon Jun 8, 2024
eb78053
fixup!: missing license header
sgammon Jun 8, 2024
ad5e68c
chore: dispatch graalvm ci as sub-workflow
sgammon Jun 8, 2024
84090b5
fixup!: job names for gvm ci
sgammon Jun 8, 2024
c91b6ea
fixup!: drop daemon jvm props
sgammon Jun 8, 2024
c0183be
fixup!: reusable workflow issues
sgammon Jun 8, 2024
49666a4
fixup!: fail on native image build err
sgammon Jun 8, 2024
40ba080
fixup!: restore main ci
sgammon Jun 8, 2024
51b6a30
fixup!: `nativeRun` task
sgammon Jun 8, 2024
1525c23
fixup!: mkdirs for gvm target directories
sgammon Jun 8, 2024
9bba1dd
feat(graalvm): add `Library` proxy auto-config
sgammon Jun 8, 2024
46460e9
chore: general nit cleanup
sgammon Jun 8, 2024
0c905a0
chore: add @sgammon and @darvld to developers of graalvm integration
sgammon Jun 10, 2024
66e6fad
chore: cleanups for codeql
sgammon Jun 10, 2024
1ecf5be
chore: dependency graph submission
sgammon Jun 10, 2024
6bb32c5
fixup!: java version
sgammon Jun 10, 2024
93d065a
fixup!: token permissions for dependency graph
sgammon Jun 10, 2024
423f82d
chore: local deploy capability
sgammon Jun 10, 2024
321ed51
fixup!: security manager for ci build
sgammon Jun 10, 2024
fde7283
fixup!: conditional java security manager fix
sgammon Jun 10, 2024
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
39 changes: 37 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ jobs:
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up JDK
uses: actions/setup-java@v4
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
Expand All @@ -43,6 +48,14 @@ jobs:
brew install automake --force
brew install libtool --force
brew install texinfo --force
- name: Java Flags
run: |
# if java is greater than 17, we need to enable the security manager
if [ ${{ matrix.java }} -gt 17 ]; then
export ANT_OPTS="-Djava.security.manager=allow"
# enable for subsequent tasks
echo "ANT_OPTS=-Djava.security.manager=allow" >> $GITHUB_ENV
fi
- name: Checkstyle
if: contains(matrix.os, 'ubuntu') && contains(matrix.java, '8')
run: |
Expand All @@ -52,3 +65,25 @@ jobs:
run: |
ant test
ant test-platform
- name: Local Deploy
run: ant deploy-local
- uses: actions/upload-artifact@v4
with:
name: jna-maven-bundle-${{ matrix.os }}-jdk${{ matrix.java }}-${{ github.sha }}
path: build/stage
if-no-files-found: error
retention-days: 14
compression-level: 1
overwrite: true

# test-graalvm:
# strategy:
# matrix:
# java: [21]
# os: [ubuntu-latest]
# fail-fast: true
# name: GraalVM Native
# uses: ./.github/workflows/graalvm.yaml
# with:
# runner: ${{ matrix.os }}
# java: ${{ matrix.java }}
64 changes: 64 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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: ["feat/static-graalvm-jni"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["feat/static-graalvm-jni"]
schedule:
- cron: "0 0 * * 1"

permissions:
contents: read

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

strategy:
fail-fast: false
matrix:
language: ["java"]

steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Initialize CodeQL
uses: github/codeql-action/init@6ac9fc7e8e290bda8fac86290b68e176def71959 # v2.25.8
with:
languages: ${{ matrix.language }}
- uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1
with:
java-version: '22'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Linux requirements
run: sudo apt-get -y install texinfo
- uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
- name: "Build: JNA Libraries"
run: ant dist
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@6ac9fc7e8e290bda8fac86290b68e176def71959 # v2.25.8
with:
category: "/language:${{matrix.language}}"
68 changes: 68 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-graph:
runs-on: ubuntu-latest
name: "Dependency Graph"
permissions:
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Set up JDK
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 21
distribution: 'zulu'
- name: 'Checkout Repository'
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Linux requirements
run: sudo apt-get -y install texinfo
- name: Build JNA Libraries
run: |
ant dist
- name: "Submit Dependency Snapshot (JNA)"
uses: advanced-security/maven-dependency-submission-action@5d0f9011b55d6268922128af45275986303459c3 # v4.0.3
with:
directory: build
maven-args: '-f pom-jna.xml'
- name: "Submit Dependency Snapshot (JNA JPMS)"
uses: advanced-security/maven-dependency-submission-action@5d0f9011b55d6268922128af45275986303459c3 # v4.0.3
with:
directory: build
maven-args: '-f pom-jna-jpms.xml'
- name: "Submit Dependency Snapshot (JNA GraalVM)"
uses: advanced-security/maven-dependency-submission-action@5d0f9011b55d6268922128af45275986303459c3 # v4.0.3
with:
directory: build
maven-args: '-f pom-jna-graalvm.xml'
- name: "Submit Dependency Snapshot (JNA Platform)"
uses: advanced-security/maven-dependency-submission-action@5d0f9011b55d6268922128af45275986303459c3 # v4.0.3
with:
directory: build
maven-args: '-f pom-jna-platform.xml'
- name: "Submit Dependency Snapshot (JNA JPMS Platform)"
uses: advanced-security/maven-dependency-submission-action@5d0f9011b55d6268922128af45275986303459c3 # v4.0.3
with:
directory: build
maven-args: '-f pom-jna-platform-jpms.xml'

dependency-review:
runs-on: ubuntu-latest
needs: [dependency-graph]
name: "Dependency Review"
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: 'Checkout Repository'
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: 'Dependency Review'
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1
64 changes: 64 additions & 0 deletions .github/workflows/graalvm.workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# GraalVM build and native test.
name: GraalVM CI (Reusable)

on:
workflow_dispatch:
inputs:
runner:
description: 'The operating system to run the tests on'
default: 'ubuntu-latest'
type: string
java:
description: 'The Java version to run the tests with'
default: 21
type: number
workflow_call:
inputs:
runner:
description: 'The operating system to run the tests on'
default: 'ubuntu-latest'
type: string
java:
description: 'The Java version to run the tests with'
default: 21
type: number
push:
branches:
- master

permissions:
contents: read

env:
ANT_OPTS: -Djava.security.manager=allow

jobs:
build:
runs-on: ${{ inputs.runner }}
name: Test GVM ${{ inputs.java }}, ${{ inputs.runner }}

steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1
with:
java-version: '${{ inputs.java }}'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Linux requirements
if: contains(inputs.runner, 'ubuntu')
run: sudo apt-get -y install texinfo
- name: macOS requirements
if: contains(inputs.runner, 'macos')
run: |
brew update
brew install automake --force
brew install libtool --force
brew install texinfo --force
- uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
- name: "Build: Native Image"
run: ant dist && ant install && ant nativeImage && ant nativeRun
39 changes: 39 additions & 0 deletions .github/workflows/graalvm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# GraalVM build and native test.
name: GraalVM CI

on:
workflow_dispatch:
workflow_call:
pull_request:
push:
branches:
- master

permissions:
contents: read

env:
ANT_OPTS: -Djava.security.manager=allow

jobs:
build:
runs-on: ubuntu-latest
name: Test GVM 22, ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1
with:
java-version: '22'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Linux requirements
run: sudo apt-get -y install texinfo
- uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
- name: "Build: Native Image"
run: ant dist && ant install && ant nativeImage && ant nativeRun
11 changes: 8 additions & 3 deletions .github/workflows/native-libraries-macOS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ jobs:
name: Build native libraries for mac OS / darwin

steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
Expand All @@ -35,7 +40,7 @@ jobs:
ant -Dos.prefix=darwin-aarch64
ant -Dos.prefix=darwin-x86-64
- name: Upload mac OS binaries
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: darwin-native
path: |
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '20 7 * * 2'
push:
branches: ["feat/static-graalvm-jni"]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
contents: read
actions: read

steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- name: "Checkout code"
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@6ac9fc7e8e290bda8fac86290b68e176def71959 # v2.25.8
with:
sarif_file: results.sarif
Loading