Feature/Implement Companion Edition API and OpenCRE Endpoints#2887
Feature/Implement Companion Edition API and OpenCRE Endpoints#2887prakhar0x01 wants to merge 11 commits intoOWASP:masterfrom
Conversation
|
Please review the changes, thanks, |
|
There are some linting issues: /home/runner/work/cornucopia/cornucopia/cornucopia.owasp.org/src/domain/cre/creController.test.ts /home/runner/work/cornucopia/cornucopia/cornucopia.owasp.org/src/domain/cre/creController.ts /home/runner/work/cornucopia/cornucopia/cornucopia.owasp.org/src/lib/filesystem/fileSystemHelper.test.ts /home/runner/work/cornucopia/cornucopia/cornucopia.owasp.org/src/lib/services/deckService.ts /home/runner/work/cornucopia/cornucopia/cornucopia.owasp.org/src/routes/api/cre/[edition]/[lang]/server.test.ts ✖ 9 problems (5 errors, 4 warnings) |
Related Issue : #2886
Summary
This PR implements the public API endpoints and OpenCRE mappings for the Companion Edition (AI/LLM threat modeling), bringing it into parity with the existing WebApp and MobileApp editions. It also introduces a new generic Language Metadata API and enhances the data loading resilience of the
DeckService.Changes
1. Core API Logic & Registration
DeckService.ts: Registered thecompanionedition (v1.0, EN) in the central registry.CreController.ts: Added human-readable mapping for "OWASP Cornucopia Companion Edition" and the "AI / LLM Application" category tag.[edition]/[lang]/+server.ts: Updated the CRE route guard to allowcompanionas a valid edition.2. New Endpoints
GET /api/cre/companion: Returns metadata for the Companion edition.GET /api/cre/companion/en: Returns the Companion card deck with OpenCRE mappings.GET /api/lang/[edition]/[version]: A new generic endpoint providing language metadata for any version/edition (supporting/api/lang/companion/1.0).3. Resilience & Bug Fixes
DeckServiceto handle missing markdown files gracefully. Instead of skipping cards when technical notes are missing, it now falls back to the YAML description, ensuring the Companion API remains functional even without full markdown documentation.source/companion-mappings-1.0.yamlat line 235 that was causing aYAMLExceptionduring build/dev.4. Infrastructure & Documentation
script/headers.jsandscript/headers-stage.jsto include the required CORS and Content-Type overrides for the new endpoints in production and staging environments.svelte.config.jsto include the new companion endpoints in the static build process.static/api/openapi.yaml.Verification Results
GET /api/cre/companionreturns correct metadata.GET /api/cre/companion/ensuccessfully returns the 1.0 card list.GET /api/lang/companion/1.0returns versioned language info./api/docsreflects new companion endpoints.npm run buildsucceeds with correct_headersgeneration.