Skip to content

Add OpenCRE mapping script with safe fallback handling#1382

Open
Nik-ui wants to merge 3 commits intoOWASP:masterfrom
Nik-ui:feature/opencre-json-mapping
Open

Add OpenCRE mapping script with safe fallback handling#1382
Nik-ui wants to merge 3 commits intoOWASP:masterfrom
Nik-ui:feature/opencre-json-mapping

Conversation

@Nik-ui
Copy link
Copy Markdown
Contributor

@Nik-ui Nik-ui commented Apr 2, 2026

This PR covers issue #623.

  • This PR handles the issue and requires no additional PRs.
  • You have validated the need for this change.

What did this PR accomplish?

  • Introduced an OpenCRE enrichment script for WSTG checklist entries
  • Implemented safe fallback handling for missing mappings to prevent runtime failures
  • Added logging for unmapped WSTG test IDs to improve visibility
  • Ensured existing checklist data remains unchanged when mappings are unavailable

@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 2, 2026

Hi @kingthorin

This PR introduces OpenCRE mapping enrichment with fallback handling for missing mappings.
Happy to make any adjustments based on feedback , thanks for your review.

@kingthorin
Copy link
Copy Markdown
Collaborator

Could you remove the unrelated commits?

If you're not comfortable with that it's okay, I can tiddy it up. Just let me know.

@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 2, 2026

Could you remove the unrelated commits?

If you're not comfortable with that it's okay, I can tiddy it up. Just let me know.

@kingthorin Okay, i will work on this.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from 13d3476 to 77f59f7 Compare April 2, 2026 15:25
@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 2, 2026

Thanks @kingthorin, I have cleaned up the branch and removed the unrelated commits. Let me know if anything else should be adjusted.

@kingthorin
Copy link
Copy Markdown
Collaborator

Need to ensure the two workflows that work with the checklist are using the same indenting rule(s). So that it isn't always the entire file that's updated. Also this should probably be a step in the other workflow, so that the CRE IDs are updated whenever the checklist(s) are.

@kingthorin kingthorin force-pushed the feature/opencre-json-mapping branch from 77f59f7 to 5702ea9 Compare April 4, 2026 23:14
@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 5, 2026

Need to ensure the two workflows that work with the checklist are using the same indenting rule(s). So that it isn't always the entire file that's updated. Also this should probably be a step in the other workflow, so that the CRE IDs are updated whenever the checklist(s) are.

Thanks @kingthorin , that makes sense.

I’ll update the script to follow the same indentation rules to avoid rewriting the entire file, and look into integrating it as part of the existing workflow so CRE IDs stay in sync with checklist updates.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch 2 times, most recently from 10c6597 to ab8d27b Compare April 5, 2026 23:24
@kingthorin
Copy link
Copy Markdown
Collaborator

Re-duplicates see these issues and the associated PR on 640:

@kingthorin
Copy link
Copy Markdown
Collaborator

@Nik-ui It seems like you still have some changes that were already merged.

You might need to reset the branch to a clean up-to-date state and re-implement your changes. Then force push to the PR. 🤷‍♂️

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from 8c5ed80 to 0e81e55 Compare April 6, 2026 01:11
@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 6, 2026

@Nik-ui It seems like you still have some changes that were already merged.

You might need to reset the branch to a clean up-to-date state and re-implement your changes. Then force push to the PR. 🤷‍♂️

Thanks @kingthorin , I have now rebased the branch onto the latest upstream master and removed previously merged or unrelated changes.

The PR now only contains the OpenCRE mapping script and workflow integration. I also verified that it does not introduce any direct checklist modifications; the existing WSTG-INPV-13 duplication is already present in upstream and is not added by this branch.

Please let me know if anything else should be adjusted.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from 0e81e55 to b49af20 Compare April 6, 2026 01:24
@kingthorin
Copy link
Copy Markdown
Collaborator

Thanks, I'll review/test tomorrow.

- name: Generate JSON Checklist
run: |
npm run-script jsongen
npm run-script opencregen
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think a npm i puppeteer-core is needed first.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still needs to be addressed

This comment was marked as outdated.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from b5eb8e7 to 2b7489a Compare April 6, 2026 17:56
@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 8, 2026

Thanks @kingthorin for the guidance, this was really helpful.

I have updated the implementation to use the /rest/v1/standard/... ?section= endpoint as suggested (OWASP/OpenCRE#866). The script now directly retrieves CRE mappings for each WSTG section from the structured standards response instead of relying on text search.

This aligns better with the intended API usage and avoids regex-style lookups.

I have tested the endpoint across multiple WSTG IDs and confirmed that it returns consistent CRE mappings.

Please let me know if this approach looks correct or if there is anything else you would like adjusted.

@kingthorin
Copy link
Copy Markdown
Collaborator

Thanks for collaborating with the OpenCRE team, that should help ensure this is more stable and reliable going forward.

Have you tested locally or on a VM? (It's okay if you haven't, I just want to set my own expectations 😉).

@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 8, 2026

Yes, I tested this locally.

I verified the mapping logic by calling the endpoint directly for multiple WSTG IDs (e.g. WSTG-INPV-04, WSTG-CONF-02) and confirmed that the expected CRE IDs are returned.

I also ran the full checklist generation script to ensure it integrates correctly and only updates the file when mappings change.

let me know if anything else should be adjusted.
TEST

@kingthorin kingthorin requested a review from Copilot April 8, 2026 12:32
@kingthorin kingthorin added enhancement A new or improved feature for the WSTG or repo repo A task specifically related to the project repository labels Apr 8, 2026
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't seem to be maintaining format.

@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 8, 2026

Thanks @kingthorin, I have now addressed the remaining feedback.

What changed

  • added explicit Node dependency installation before checklist generation
  • updated the OpenCRE enrichment to use the standards endpoint with ?section=
  • added timeout, retry with backoff, small concurrency limiting, and request caching
  • preserved existing cre_ids via PREVIOUS_CHECKLIST_PATH when OpenCRE has no mapping or fails
  • treated 404 responses as “no mapping found” rather than hard errors
  • improved logging so mapped / unchanged / unmapped / errored cases are clearer
  • added a Node engine requirement since the script uses global fetch

Validation

I tested locally and confirmed:

  • mapped sections are enriched correctly
  • unmapped sections are handled safely without failing the run
  • rerunning the enrichment is idempotent (No checklist changes needed. on the second run)
  • the checklist is no longer being rewritten unnecessarily

I also removed the sorting of existing cre_ids so the script preserves current ordering and avoids noisy diffs.

One note on schema: I kept cre_ids as an array because the current OpenCRE standards response can return multiple CRE mappings for a single WSTG section, so a singular CRE_ID would lose data.

Please let me know if you would like me to make any further adjustments.

@kingthorin
Copy link
Copy Markdown
Collaborator

Doing the existing vs the new as a secondary step seems unnecessary. Should be able to read the JSON and compare/update in a single pass. (Also seems weird to have a script for js but then also inline a ton of js.)

I still don't see puppeteer being installed.

@kingthorin
Copy link
Copy Markdown
Collaborator

Hold off on further changes for now. I'm going to look at adjusting the current generation/handling. Then we can come back around to this.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch 2 times, most recently from 7725dec to b479b1c Compare April 8, 2026 23:29
@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 9, 2026

Hold off on further changes for now. I'm going to look at adjusting the current generation/handling. Then we can come back around to this.

Okay.

@kingthorin
Copy link
Copy Markdown
Collaborator

After a bunch of debate and testing I decided to move away from the shell handling to python since that was already in use for the Excel and Google Drive handling.

Do you want:

  • To re-work this using python?
  • Me to re-work this using python?
  • You to close this and me to tackle it in a new branch/PR?

@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 11, 2026

After a bunch of debate and testing I decided to move away from the shell handling to python since that was already in use for the Excel and Google Drive handling.

Do you want:

  • To re-work this using python?
  • Me to re-work this using python?
  • You to close this and me to tackle it in a new branch/PR?

Hi @kingthorin, I will definitely give this a try and get back to you once I am done.

@kingthorin
Copy link
Copy Markdown
Collaborator

Do you plan to clean this up and finish it?

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from 93bb741 to 95f6fa3 Compare April 14, 2026 17:43
@github-actions

This comment has been minimized.

@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 14, 2026

Do you plan to clean this up and finish it?

currently on it.

@github-actions

This comment has been minimized.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from dc3c166 to 95f6fa3 Compare April 14, 2026 18:56
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from 159a2be to 46653bf Compare April 14, 2026 19:44
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from a696d90 to 0187adc Compare April 14, 2026 20:35
@github-actions

This comment has been minimized.

@Nik-ui Nik-ui force-pushed the feature/opencre-json-mapping branch from 1ea467a to 2d43dae Compare April 14, 2026 22:11
@kingthorin
Copy link
Copy Markdown
Collaborator

If you need help I can probably get it back on track and provide instructions to update your local branch. Just let me know.

@Nik-ui
Copy link
Copy Markdown
Contributor Author

Nik-ui commented Apr 15, 2026

If you need help I can probably get it back on track and provide instructions to update your local branch. Just let me know.

Quick update: I have now fixed the markdown and link-check issues, and all checks are passing.

The PR is currently down to 3 commits and appears ready for review on my side. I’d still appreciate your guidance on the best next step for getting this fully aligned with the intended Python-based approach, if that’s still the preferred direction.

@github-actions

This comment has been minimized.

@kingthorin
Copy link
Copy Markdown
Collaborator

The files currently in the PR are completely irrelevant to the OpenCRE work. They seem to be something that you added during a merge or rebase.

The shell script was removed from the repo during the period in which you've been working with this PR. (So that was probably either from a merge or conflict.)

I'll go through the history tomorrow and try to find the python you had submitted at one point. Then I'll try to put some instructions together to get you back on track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A new or improved feature for the WSTG or repo repo A task specifically related to the project repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants