Skip to content

Bump OpenICF to 2.1.0-SNAPSHOT and fix CodeQL note-level findings - #259

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:codescan-deps-openicf-2.1.0
Open

vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:codescan-deps-openicf-2.1.0

Conversation

@vharseko

Copy link
Copy Markdown
Member

Summary

Code scanning triage of the open alerts on master.

Dependencies

  • Import the openicf 2.1.0-SNAPSHOT BOM instead of 2.0.4.

Note: the current 2.1.0-SNAPSHOT still pins opendj 5.1.2 → commons 3.1.2 (jackson 2.18.6, bcprov 1.84), and xml-connector 2.1.0-SNAPSHOT still bundles lib/xercesImpl-2.6.2.jar. The Trivy alerts on those artifacts close once the fixed versions land upstream in the OpenICF snapshot.

CodeQL note-level findings

Alert File Change
#974 java/local-variable-is-never-read RepoJobStore Drop the unused jobKey local.
#975 java/non-static-nested-class RepoJobStore TriggerComparator is static; it never uses the enclosing instance.
#967 js/unused-local-variable populateAsManagedUser.js Drop the unused propertyMapping.
#966 js/unused-local-variable TemporalConstraintsFormView.js Drop the unused constraint.

Dismissed as false positives (5):

Test plan

  • openidm-quartz-fragment built with -am against openicf 2.1.0-SNAPSHOT; tests 8/8 pass
  • node --check on both edited JS files
  • Full build in CI
  • CodeQL on this PR closes #966, #967, #974, #975

- Import the openicf 2.1.0-SNAPSHOT BOM instead of 2.0.4.
- RepoJobStore: drop the unused jobKey local (code scanning #974) and
  make TriggerComparator static, as it never uses the enclosing
  instance (#975).
- populateAsManagedUser.js: drop the unused propertyMapping (#967).
- TemporalConstraintsFormView.js: drop the unused constraint (#966).
@vharseko vharseko added dependencies Pull requests that update a dependency file java Pull requests that update Java code javascript Pull requests that update Javascript code ui Admin and end-user web UI (openidm-ui-*) refactor Code refactoring without behavior change labels Oct 13, 2026
@vharseko
vharseko requested a review from maximthomas October 13, 2026 12:15
vharseko added a commit to OpenIdentityPlatform/OpenICF that referenced this pull request Oct 19, 2026
…sses (#191)

## Summary

#134 replaced `Class.newInstance()` with `ReflectionUtil.newInstance()`,
which goes through `MethodHandles.Lookup.findConstructor`. That changed
how a connector configuration class with a missing dependency fails:

- **before:** `Class.newInstance()` threw `NoClassDefFoundError`. The
`catch (Exception)` in `createDefaultAPIConfiguration` let it through,
and `LocalConnectorInfoManagerImpl` (`catch (NoClassDefFoundError)`,
likewise the OSGi managers) skipped that connector and logged an error;
- **now:** `findConstructor` reports the same `NoClassDefFoundError` as
`IllegalAccessException: no such constructor`. That is an `Exception`,
so it is wrapped in a `ConnectorException` that nobody catches, and the
whole bundle scan fails.

Found through OpenIdentityPlatform/OpenIDM#259 (bump to openicf
2.1.0-SNAPSHOT): `ScriptedCRESTConfiguration` in `groovy-connector`
refers to `httpasyncclient`, which is not on the OpenIDM test classpath,
and `ConnectorInfoProviderServiceTest.beforeTest` fails with
`LocalManager initialisation failed`; 126 tests of the module are
skipped.

```
Caused by: ConnectorException: java.lang.IllegalAccessException: no such constructor: org.forgerock.openicf.connectors.scriptedcrest.ScriptedCRESTConfiguration.<init>()v
  at LocalConnectorInfoManagerImpl.createDefaultAPIConfiguration(LocalConnectorInfoManagerImpl.java:339)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/nio/client/HttpAsyncClient
```

## Fix

`ReflectionUtil.newInstance` rethrows the `LinkageError` cause of the
`findConstructor` failure, except for the `NoSuchMethodError` and
`IllegalAccessError` that come with a missing or inaccessible
constructor (those are still reported as `NoSuchMethodException` /
`IllegalAccessException`). This brings back the `Class.newInstance()`
behaviour for every caller, including the OSGi info managers. One case
stays different: a link failure that is itself an `IllegalAccessError`
(a dependency that cannot access its superclass) cannot be told from an
inaccessible constructor, so it is still reported as
`IllegalAccessException`. `Class.newInstance()` threw the raw
`IllegalAccessError`. The managers catch neither, so the scan fails in
both cases.

## Test plan

- [x] New
`ReflectionUtilTests.newInstanceThrowsLinkageErrorOfClassWithMissingDependency`:
a class loader that cannot load one dependency, so the class fails to
link. Before the fix the test fails with the same
`IllegalAccessException: no such constructor`
- [x] New
`ReflectionUtilTests.newInstanceFailsOnInaccessibleConstructor`: a
private constructor seen through `publicLookup()` still fails with
`IllegalAccessException`, not with a raw `IllegalAccessError`
- [x] New `ReflectionUtilTests.newInstanceFailsOnInaccessibleClass`: a
package-private class seen through `publicLookup()`, which
`findConstructor` reports without a cause, still fails with
`IllegalAccessException`, not with a `NullPointerException`
- [x] New
`LocalConnectorInfoManagerTests.testSkipsConnectorWithUnlinkableConfiguration`:
a bundle with two connectors, the configuration class of one refers to a
class missing from the bundle; the scan lists the other connector.
Without the fix it fails with the `IllegalAccessException: no such
constructor` from OpenIDM#259; without the `catch
(NoClassDefFoundError)` in `LocalConnectorInfoManagerImpl` it fails with
the `NoClassDefFoundError`. The test closes the bundle class loader
before it deletes the temp jar, which Windows cannot delete while it is
open
- [x] `connector-framework`: 205/205 pass (incl.
`newInstanceFailsWithoutNoArgConstructor`, which still gets
`NoSuchMethodException`); `connector-framework-internal`: 525 run, 0
failures, 2 skipped (`testConfigurationUpdate` of the remote manager
tests)
- [x] End to end: with this `connector-framework` installed locally,
OpenIDM `openidm-provisioner-openicf` on openicf 2.1.0-SNAPSHOT passes
138/138 (same as on 2.0.4; without the fix `beforeTest` fails)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file java Pull requests that update Java code javascript Pull requests that update Javascript code refactor Code refactoring without behavior change ui Admin and end-user web UI (openidm-ui-*)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants