Skip to content

[#263] 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 - #264

Merged
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix/263-codeql-jdk
Oct 28, 2026
Merged

vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix/263-codeql-jdk

Conversation

@vharseko

@vharseko vharseko commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Fixes #263

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. Code scanning then opened alerts for APIs deprecated only after Java 17, the version the release is built with. The details are in #263.

Fix

  • Before Initialize CodeQL, the java-kotlin job sets up the JDK that the release is built with, with the actions/setup-java parameters of release.yml: temurin, 8 on sustaining/6.3.x and 17 otherwise. The branch is taken from github.base_ref for a pull request and from github.ref_name for a push.

The other languages do not use the step. The same change for OpenDJ is OpenIdentityPlatform/OpenDJ#1232.

Test

The change 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: 17... from Eclipse Adoptium, where master shows Java version: 25.0.4.1.

A pull request analysis only reports results on the changed lines, so it cannot show the alerts going away. They are closed by the first analysis of master after the merge.

Also in this PR: the OpenDJ wait of the usecase smoke tests

The run of this PR failed all four ui-smoke-tests (…, samples/usecase/usecase1) legs with OpenDJ did not start. The cause has nothing to do with CodeQL. On 2026-10-21 openidentityplatform/opendj:latest moved to 5.2.0. Its run.sh no longer logs OpenDJ is started, the line the Start OpenDJ for usecase samples step waited for, although the server came up (The Directory Server has started successfully). Every usecase run fails the same way now, master included.

The step now waits up to 5 minutes for the health status healthy of the container, the same check build-docker uses for the OpenIDM image. In 5.2.0 healthy means the bootstrap is complete (the LDIF is imported and the server is started again) and LDAPS answers. The 5 minutes match the --start-period of the image's HEALTHCHECK.

Checked locally with opendj:latest (5.2.0) and the arguments of the workflow: the wait ends on healthy, and a bind as cn=Directory Manager on 1389 finds the 33 entries of hr_data.ldif.

The failed build-docker of the same run (an empty image tag from an anonymous call to the releases API) is fixed separately in #265.

…QL Java analysis, so that its results no longer follow the default JDK of the runner image

Fixes OpenIdentityPlatform#263

With build-mode 'none' CodeQL infers no JDK from the project and models
the JDK API on the java found on the PATH. When ubuntu-latest moved to
ubuntu-26.04 on 2026-10-19 that java became 25 instead of 17, and code
scanning opened alerts for APIs deprecated only after Java 17, the
version the release is built with.

The java-kotlin job now sets up the JDK of the release before Initialize
CodeQL, with the setup-java parameters of release.yml: temurin, 8 on
sustaining/6.3.x and 17 otherwise.
@vharseko vharseko added bug Something isn't working security Security fix / CVE remediation ci CI/CD, build and release workflows labels Oct 22, 2026
@vharseko
vharseko requested a review from maximthomas October 22, 2026 10:29

@maximthomas maximthomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: The analysis JDK now comes from the workflow instead of the runner image, and the job log shows it.

  • Set up JDK (.github/workflows/codeql.yml:63-68) runs before Initialize CodeQL, only for java-kotlin, with the actions/setup-java@v6 tag and temurin distribution of release.yml:47-50.
  • Run 39763486253's java-kotlin job logs Setting Java 17.0.20+1 as the default and the extractor's No specific JDK inferred from the project being analysed; using the java on the PATH, the mechanism the description states.
  • JDK 17 carries no @Deprecated on URL(String) or MemoryMXBean.getObjectPendingFinalizationCount() (checked on 17.0.11; 25.0.2 has since="20" / since="18"), so alerts 995-999 have nothing to match under the new model.

Since 5.2.0, which openidentityplatform/opendj:latest points to from
2026-10-21, the image no longer logs "OpenDJ is started", so the step
timed out with "OpenDJ did not start" although the server was up.
Wait for the container to turn healthy instead: from 5.2.0 on that
means the bootstrap LDIF is imported and the server is started again.
@vharseko vharseko added the test Tests and test infrastructure (unit, e2e, smoke) label Oct 27, 2026
vharseko added a commit that referenced this pull request Oct 28, 2026
…kflow token (#265)

### Problem

The `build-docker` and `build-docker-alpine` jobs get the version for
the image tag from an anonymous `curl` to
`api.github.com/repos/OpenIdentityPlatform/OpenIDM/releases/latest`. In
run
[39763486259](https://github.com/OpenIdentityPlatform/OpenIDM/actions/runs/39763486259)
of #264 the answer to `build-docker` had no `"name"`. The step printed
`last release: ` and still passed, the tag came out empty, and
`build-push-action` failed with `tag is needed when pushing to
registry`. `build-docker-alpine` of the same run got `7.1.2`.

The step does not log the answer. The likely cause is the rate limit for
anonymous API calls, which the runner's IP shares with other jobs. Two
more weaknesses hid the failure:

- `export var="$(...)"` returns the status of `export`, so a failed call
cannot fail the step;
- an empty version passes the step, so the failure surfaces two steps
later as a buildx error.

### Fix

In both jobs the `Get latest release version` step:

- calls the API through `gh api ... --jq .name` with `GH_TOKEN: ${{
github.token }}`. The jobs already have `contents: read`. An
authenticated call has its own rate limit and does not share the
runner's IP limit;
- assigns the version without `export`, so a failed `gh` call fails the
step through `-e` and logs its error;
- fails with `test -n` when the version is empty.

### Test

- Locally `gh api repos/OpenIdentityPlatform/OpenIDM/releases/latest
--jq .name` returns `7.1.2`, the same value the old `grep`/`cut` gave.
- In the run of this PR, both `build-docker` and `build-docker-alpine`
must print `last release: 7.1.2` and build the image.
@vharseko
vharseko merged commit d3d5567 into OpenIdentityPlatform:master Oct 28, 2026
31 checks passed
@vharseko
vharseko deleted the fix/263-codeql-jdk branch October 28, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci CI/CD, build and release workflows security Security fix / CVE remediation test Tests and test infrastructure (unit, e2e, smoke)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeQL: the Java analysis takes its JDK from the runner image, which moved from Java 17 to 25 with ubuntu-26.04

2 participants