Repository navigation
ACOMMONS-237 Export the S5332 identifier URL inventory through the shared npm package - #592
Conversation
There was a problem hiding this comment.
Exports the Java filter’s cleartext exclusions and identifier inventory as JSON, so SonarJS can consume the same configuration without maintaining a duplicate list.
There was a problem hiding this comment.
Publishes shared regression examples so consumers can check that their matching behavior agrees with Java. Keeping these examples in the configurations module avoids adding test data to the Commons runtime JAR.
There was a problem hiding this comment.
Verifies the documented Node.js imports against the assembled npm package and checks its contents against the generated JSON. This catches packaging mistakes that the Java exporter unit tests cannot detect.
There was a problem hiding this comment.
Adds Node.js to the repository’s tools so the npm package import check can run locally and in CI.
daniel-teuchert-sonarsource
left a comment
There was a problem hiding this comment.
I see that this PR also introduces new endpoints to filter out.
Can we please do that in a separate PR?
The title of this PR suggests that this change is only about exporting the URL filtering as an npm package.
daniel-teuchert-sonarsource
left a comment
There was a problem hiding this comment.
Thanks for the clean up!
That makes this already so much easier to review 👍
I compared this PR with the existing secret-classifier exports. I think we can align a few things with that approach:
- Reuse RegexTranslator for host patterns. The new exporter writes pattern.pattern() directly, while SecretPatternsExporter calls RegexTranslator.toPortableRegex(...). The current patterns compile in JavaScript, but reusing the translator would protect against future Java-specific regex changes.
- Include matching semantics in the JSON. The secret exporter’s match metadata explicitly declares search semantics and case sensitivity. We could similarly declare case-insensitive search for host patterns and case-insensitive prefix matching against the complete URL for safeUrlPrefixes, alongside the README documentation.
- Test the exported configuration’s behavior. The new corpus tests call the original Java filter, while the npm test checks imports and JSON equality. In comparison, SecretExclusionCorpusExporterTest loads the exported patterns and verifies that they suppress every known non-secret and preserve every secret candidate. We should similarly exercise the exported host patterns and prefixes here, then run the complete URL corpus against SonarJS because URL parsing differs between runtimes.
- Use one shared set of regression cases. Rather than maintaining URL_SAMPLES separately from the filter tests, both should consume shared cases. For secrets, SecretClassifierTest and SecretExclusionCorpusExporter both use exportKnownNonSecretSamples(...). For cleartext, we should follow that shared-source principle while keeping the samples outside the runtime JAR.
- Please remove the Node entry in mise.toml and the verify-npm-package-import execution and script for now. Keep Java/Maven verification consistent with the existing exports, and validate npm imports and runtime behavior in SonarJS. As this was sufficient for the secret classifier export I'd argue that it should also be enough here.
fe00044 to
02e5e09
Compare
daniel-teuchert-sonarsource
left a comment
There was a problem hiding this comment.
LGTM!
Thanks for the adjustments!
…ented in following PR. Added tests to test the functionality of the
…rterTest as an example.
…aintainability as the existing secrect exclustion logic.
02e5e09 to
eb383eb
Compare
Code Review ✅ Approved 🟡 Medium risk 2 closed / 2 findingsExporting cleartext URL exclusions to the npm package could suppress insecure-URL findings in consuming analyzers if the matching semantics are misapplied. Exports the S5332 identifier URL inventory through the shared npm package, with the URL samples map removal and the stacked PR #593 adding identifier samples back. No open issues found; the SonarJS identifier-urls.json import is closed without a fix in this PR. ✅ 2 closed✅ Cross-PR: #593 still adds identifier samples to the URL_SAMPLES map removed here
Closed: Cross-PR: SonarJS imports identifier-urls.json, which this package never ships
Verification Rules 2/2 met Repos 1 inspected · PRs 2 inspectedFunctional validation No results Rules 2 passed 3 not applicable
Broader impact Repos 1 inspected PRs 2 inspectedCross-repo 1 repository inspected 0 open impacts
Cross-PR 2 PRs inspected 0 open impacts
Auto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Summary by Gitar
CleartextProtocolFilter.exportHostPatternsandexportSafeUrlPrefixesto expose existing exclusions for non-JVM analyzersCleartextProtocolFilterExporterandCleartextProtocolCorpusExporterwriting JSON files into the npm packagepackage.jsonprepare-packageand packaged it throughnpm.xmlcleartext-protocol-corpus.jsonvia configurationspom.xmlresources without packaging it in the Commons JARThis will update automatically on new commits.