mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
yesterday d3fecb7575a9e9e4401774167c6816198eac46d7
[#1231] Set up the JDK of the release for the CodeQL Java analysis, so that its results no longer follow the default JDK of the runner image (#1232)

Fixes #1231

### Problem

The java-kotlin job of the CodeQL workflow runs with `build-mode: none`
and sets up no JDK. CodeQL infers no JDK from the project (`No specific
JDK inferred from the project being analysed; using the java on the
PATH`), so it models the JDK API on the default `java` of the runner
image. On 2026-10-19 `ubuntu-latest` moved from ubuntu-24.04 to
ubuntu-26.04, and that `java` changed from 17 to 25. Without a change to
the code, code scanning opened 20 `java/deprecated-call` alerts
(1318–1337) for APIs deprecated in Java 18–21, so only after Java 11,
the version the release is built with. The details are in #1231.

### Fix

- Before `Initialize CodeQL`, the java-kotlin job sets up the JDK that
the release is built with. It uses the `release.yml` setup: temurin, 8
on `sustaining/4.10.x` and 11 otherwise, with the same
`actions/setup-java` version (v6.1.0). CodeQL then models the API of the
JDK the release is built with, and the alert set no longer changes when
GitHub moves `ubuntu-latest` to a newer image. The branch is taken from
`github.base_ref` for a pull request and from `github.ref_name` for a
push.
- The new step pins `actions/setup-java` to the commit SHA of v6.1.0,
like every other action in these workflows. `build.yml`, `deploy.yml`
and `release.yml` pin the same SHA since #1234, so every workflow sets
up its JDK with the same version.
- `github/codeql-action` moves from v4.39.0, the pin of #1234, to
v4.39.1, its newest release, in `codeql.yml`, `build.yml` and
`docker-scan.yml`, also pinned to a commit SHA. It brings the CodeQL
bundle 2.27.3 instead of 2.27.2.
- The commented-out copy of the same step in the Java manual build
section is removed. If that build is turned on, the new step serves it.

The other languages (actions, ruby, c-cpp) do not use the step.

The JDK 11 model does not report these deprecations, but a removal would
still show up. If a future JDK removes `Subject.doAs`,
`Runtime.runFinalization` or
`JMXConnector.getMBeanServerConnection(Subject)`, the Build matrix fails
to compile once that JDK is added.

### Test

The change to `codeql.yml` only takes effect in a CodeQL run, so the
CodeQL run of this PR is the test. The java-kotlin job log must show
`Java version: 11...` for the temurin JDK that setup-java installs,
where master shows `Java version: 25.0.4.1`. The first revision of this
PR, with zulu 11, showed `Java version: 11.0.32, vendor: Azul Systems,
Inc.` in [run
39757355544](https://github.com/OpenIdentityPlatform/OpenDJ/actions/runs/39757355544).

The Build run of this PR runs `codeql-action/upload-sarif` v4.39.1 in
the Trivy step of `docker-test`. `docker-scan.yml` only runs on its
weekly schedule and by hand, so it first runs v4.39.1 after the merge.

A pull request analysis only reports results on the changed lines
(`pr-diff-range`), so it cannot show the 20 alerts going away. They are
closed by the first analysis of master after the merge. The master
analysis of `de42bdce8f` has 368 results. That analysis also moves to
the CodeQL bundle 2.27.3, so it may open or close alerts that have
nothing to do with the JDK.
3 files modified
28 ■■■■■ changed files
.github/workflows/build.yml 2 ●●●●● patch | view | raw | blame | history
.github/workflows/codeql.yml 24 ●●●●● patch | view | raw | blame | history
.github/workflows/docker-scan.yml 2 ●●●●● patch | view | raw | blame | history
.github/workflows/build.yml
@@ -1056,7 +1056,7 @@
          scanners: vuln
          cache: false
      - name: Upload Trivy report to GitHub Security
        uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
        uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
        # upload even if a preceding step failed, but not without a report to upload
        if: ${{ always() && hashFiles('trivy-results.sarif') != '' }}
        with:
.github/workflows/codeql.yml
@@ -84,8 +84,22 @@
        with:
          submodules: recursive
      # With build-mode 'none' CodeQL infers no JDK from this project and
      # models the JDK API on the java found on the PATH, so without this step
      # the results follow the default JDK of the runner image: ubuntu-26.04
      # brought JDK 25 and with it alerts for APIs deprecated only after
      # Java 11. Pin the JDK and distribution the release is built with
      # (release.yml): 8 on sustaining/4.10.x, 11 otherwise. It also serves
      # the Java manual build below.
      - name: Set up JDK
        if: matrix.language == 'java-kotlin'
        uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
        with:
          java-version: ${{ (github.base_ref || github.ref_name) == 'sustaining/4.10.x' && '8' || '11' }}
          distribution: 'temurin'
      - name: Initialize CodeQL
        uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
        uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
        with:
          languages: ${{ matrix.language }}
          build-mode: ${{ matrix.build-mode }}
@@ -118,12 +132,6 @@
      # ---------------------------------------------------------------------
      # --- Java manual build (only used if the java entry is set to 'manual')
      # - name: Set up JDK 11
      #   if: matrix.language == 'java-kotlin'
      #   uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
      #   with:
      #     java-version: '11'
      #     distribution: 'zulu'
      # - name: Cache Maven packages
      #   if: matrix.language == 'java-kotlin'
      #   uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
@@ -139,6 +147,6 @@
      # ---------------------------------------------------------------------
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
        uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
        with:
          category: "/language:${{ matrix.language }}"
.github/workflows/docker-scan.yml
@@ -51,7 +51,7 @@
          scanners: vuln
          cache: false
      - name: Upload report to GitHub Security
        uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
        uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
        # upload even if a preceding step failed, but not without a report to upload
        if: ${{ always() && hashFiles(format('trivy-{0}.sarif', matrix.tag)) != '' }}
        with: