@redocly/cli 2.57.0 → 2.58.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +2 -0
  2. package/THIRD_PARTY_NOTICES +45 -23
  3. package/lib/chunks/{YEACSN2C.js → 263OU3EK.js} +1 -1
  4. package/lib/chunks/2CAHRLJ3.js +22 -0
  5. package/lib/chunks/{FDOONAMV.js → 4R5JMLPR.js} +1 -1
  6. package/lib/chunks/{GVJFU4AP.js → 4U5QHDPF.js} +1 -1
  7. package/lib/chunks/{MZWBJKK2.js → 4WEATF5W.js} +1 -1
  8. package/lib/chunks/{7EB22KXX.js → 4Y6NCJUT.js} +1 -1
  9. package/lib/chunks/{XYKNLM5G.js → 5TPCSTMC.js} +1 -1
  10. package/lib/chunks/{R2FG6TUX.js → 6MXKU6BN.js} +1 -1
  11. package/lib/chunks/{OR3KBRCI.js → 6NXEK35A.js} +1 -1
  12. package/lib/chunks/6VBDC3HP.js +13 -0
  13. package/lib/chunks/{J3DL5HGI.js → 7HGHXQBL.js} +1 -1
  14. package/lib/chunks/{GHOLYNZA.js → 7INWM6QM.js} +1 -1
  15. package/lib/chunks/{VBHLPG5Q.js → AW5K6TIG.js} +1 -1
  16. package/lib/chunks/{H5OX3UOD.js → B2Q7DOT4.js} +1 -1
  17. package/lib/chunks/{UXFJO2OQ.js → BNNOQCQA.js} +1 -1
  18. package/lib/chunks/{XTTR5PBC.js → BQBQIRKC.js} +1 -1
  19. package/lib/chunks/{CWEET26O.js → BWDHENL3.js} +1 -1
  20. package/lib/chunks/{P7A7BCIN.js → CMHJY4T2.js} +1 -1
  21. package/lib/chunks/{LUW2ZJJO.js → CTTC32GG.js} +1 -1
  22. package/lib/chunks/{LI6IH6DJ.js → DEZGXWTS.js} +1 -1
  23. package/lib/chunks/{F57WBWGV.js → DTH2KLMU.js} +2 -2
  24. package/lib/chunks/{VT3BHT6S.js → ENBAORPS.js} +3 -3
  25. package/lib/chunks/{VIPV4IEH.js → FYDETXDC.js} +1 -1
  26. package/lib/chunks/{YDVOCOBI.js → GACZ2YWU.js} +1 -1
  27. package/lib/chunks/H4NHEW6K.js +9 -0
  28. package/lib/chunks/H4VN2RX3.js +7 -0
  29. package/lib/chunks/{ZVXAH4QD.js → H67F6VQQ.js} +1 -1
  30. package/lib/chunks/{65AQJO4M.js → IBYLYDST.js} +2 -2
  31. package/lib/chunks/{AOCVSFC3.js → IXAUPJML.js} +1 -1
  32. package/lib/chunks/JD3HIQIK.js +193 -0
  33. package/lib/chunks/{VUU57INZ.js → JFQX5N4D.js} +1 -1
  34. package/lib/chunks/{664FDTDV.js → JIN2S34E.js} +1 -1
  35. package/lib/chunks/{5FVKAWNE.js → K3GO5B32.js} +1 -1
  36. package/lib/chunks/{S5PUZGYS.js → K4HCHGLF.js} +1 -1
  37. package/lib/chunks/{3QGJWJKQ.js → K4MJBKZB.js} +1 -1
  38. package/lib/chunks/{YMDFCK3F.js → KIUUH6YY.js} +1 -1
  39. package/lib/chunks/{4SXCDBB7.js → KMRFAGWI.js} +1 -1
  40. package/lib/chunks/{SRCGYHDN.js → KRKCMWGM.js} +1 -1
  41. package/lib/chunks/{MKS4O6F4.js → LHKIMOHX.js} +2 -2
  42. package/lib/chunks/LRFPMBTV.js +7 -0
  43. package/lib/chunks/{X5NXRMUW.js → M7T6N7AK.js} +1 -1
  44. package/lib/chunks/ML6MFXCA.js +7 -0
  45. package/lib/chunks/{VE7VT5PT.js → MSKEZAFV.js} +1 -1
  46. package/lib/chunks/{D7WNH6Z5.js → MULE7RHG.js} +1 -1
  47. package/lib/chunks/{WKCOTH3C.js → MVXFJBMU.js} +1 -1
  48. package/lib/chunks/NMS2HUB3.js +7 -0
  49. package/lib/chunks/{GEWI247R.js → NX3RWANU.js} +1 -1
  50. package/lib/chunks/{EDU3YBRA.js → PI42YPSD.js} +1 -1
  51. package/lib/chunks/{52MXI4PU.js → PJXZKT3O.js} +1 -1
  52. package/lib/chunks/{Y2AFRRAT.js → PY4MYMQT.js} +1 -1
  53. package/lib/chunks/{DMW5VJBT.js → PZF2WPD3.js} +1 -1
  54. package/lib/chunks/Q4ESEW3O.js +160 -0
  55. package/lib/chunks/{YOBULQYM.js → QK7R3ZTY.js} +1 -1
  56. package/lib/chunks/{ZFJHZEI3.js → R2IHROCG.js} +1 -1
  57. package/lib/chunks/{N2GTHB37.js → ROQ7FTVG.js} +1 -1
  58. package/lib/chunks/RVRYLTME.js +17 -0
  59. package/lib/chunks/{ZBOUASE7.js → RW4XUFPU.js} +1 -1
  60. package/lib/chunks/SQUNMRDS.js +9 -0
  61. package/lib/chunks/T2G7FRCU.js +23 -0
  62. package/lib/chunks/{4HG5PCQA.js → TDNSQRQT.js} +1 -1
  63. package/lib/chunks/{QDSAT32N.js → TGAC4ILD.js} +1 -1
  64. package/lib/chunks/{7XKYPQPI.js → URZNERQS.js} +1 -1
  65. package/lib/chunks/{F5V42ZYY.js → V2PTVECL.js} +1 -1
  66. package/lib/chunks/{4JBK2BSL.js → VJQJVOIN.js} +1 -1
  67. package/lib/chunks/{IDI3SURO.js → WDWS64N7.js} +1 -1
  68. package/lib/chunks/{NALRPITK.js → WSDNWUOV.js} +1 -1
  69. package/lib/chunks/{JMFIKCPX.js → WYZDPMVU.js} +1 -1
  70. package/lib/chunks/{5UDC2SWY.js → XTW63JDM.js} +1 -1
  71. package/lib/chunks/YURX7H3N.js +15 -0
  72. package/lib/chunks/{DT66L2TO.js → YZRKJF2V.js} +1 -1
  73. package/lib/chunks/Z7JI42WA.js +31 -0
  74. package/lib/chunks/ZIIE7LXR.js +34 -0
  75. package/lib/chunks/index.aff +205 -0
  76. package/lib/chunks/index.dic +49569 -0
  77. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  78. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  79. package/lib/eject-assets/generators/cli/index.ts +2 -2
  80. package/lib/eject-assets/generators/cli/render.ts +1 -1
  81. package/lib/eject-assets/generators/go/client.ts +1 -1
  82. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  83. package/lib/eject-assets/generators/go/index.ts +2 -2
  84. package/lib/eject-assets/generators/go/models.ts +1 -1
  85. package/lib/eject-assets/generators/go/naming.ts +1 -1
  86. package/lib/eject-assets/generators/go/operations.ts +1 -1
  87. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  88. package/lib/eject-assets/generators/go/types.ts +1 -1
  89. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  90. package/lib/eject-assets/generators/mock/index.ts +2 -2
  91. package/lib/eject-assets/generators/mock/render.ts +1 -1
  92. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  93. package/lib/eject-assets/generators/mock/values.ts +1 -1
  94. package/lib/eject-assets/generators/php/client.ts +1 -1
  95. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  96. package/lib/eject-assets/generators/php/index.ts +2 -2
  97. package/lib/eject-assets/generators/php/models.ts +1 -1
  98. package/lib/eject-assets/generators/php/naming.ts +1 -1
  99. package/lib/eject-assets/generators/php/operations.ts +1 -1
  100. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  101. package/lib/eject-assets/generators/php/types.ts +1 -1
  102. package/lib/eject-assets/generators/python/client.ts +1 -1
  103. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  104. package/lib/eject-assets/generators/python/index.ts +2 -2
  105. package/lib/eject-assets/generators/python/models.ts +1 -1
  106. package/lib/eject-assets/generators/python/naming.ts +1 -1
  107. package/lib/eject-assets/generators/python/operations.ts +1 -1
  108. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  109. package/lib/eject-assets/generators/python/types.ts +1 -1
  110. package/lib/eject-assets/generators/swr/index.ts +2 -2
  111. package/lib/eject-assets/generators/swr/render.ts +1 -1
  112. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  113. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  114. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  115. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  116. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  117. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  118. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  119. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  120. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  121. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  122. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  123. package/lib/eject-assets/generators/typescript/operations.ts +1 -1
  124. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  125. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  126. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  127. package/lib/eject-assets/generators/zod/index.ts +2 -2
  128. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  129. package/lib/index.js +66 -61
  130. package/package.json +1 -1
  131. package/lib/chunks/2PGNW76R.js +0 -11
  132. package/lib/chunks/3I7XLHPY.js +0 -45
  133. package/lib/chunks/ARDTVDGR.js +0 -22
  134. package/lib/chunks/K2ENYHHD.js +0 -7
  135. package/lib/chunks/LJPUHAWE.js +0 -13
  136. package/lib/chunks/M4YE5ALG.js +0 -193
  137. package/lib/chunks/OM4VGI2Q.js +0 -9
  138. package/lib/chunks/VYHYEZI5.js +0 -7
  139. package/lib/chunks/YFI3NLJF.js +0 -9
  140. package/lib/chunks/YUNIBLZR.js +0 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/cli",
3
- "version": "2.57.0",
3
+ "version": "2.58.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,11 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a as v}from"./LI6IH6DJ.js";import{a as x,b as y,c as R,d as u}from"./ARDTVDGR.js";import{c as f,d as g}from"./WKCOTH3C.js";import{X as a,ca as m,da as w}from"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{mkdir as S,writeFile as O}from"node:fs/promises";import C from"node:path";async function F(e){let i=await g(e.trafficPath);if(i.length===0)throw new Error("No traffic files found in the provided traffic path.");let t=y.create({openApiIndex:e.openApiIndex,matchMode:e.matchMode,ignoreCookies:e.ignoreCookies,ignoreHeaders:e.ignoreHeaders,previewFindingsLimit:e.previewFindingsLimit,activeRules:e.activeRules,server:e.server,minSeverity:e.minSeverity}),r=0,o=0;for(let n of i){let s=await v(n,e.format);if(!s){a.warn(`Skipping traffic file with unrecognized format: ${n}
8
- `);continue}r+=1;for await(let c of s.parse(n))await t.process({...c,index:o}),o+=1}if(r===0)throw new Error("No supported traffic files found. In auto mode, files must match built-in traffic parser signatures.");if(o===0)throw new Error("No HTTP exchanges were parsed from the provided traffic files.");return t.finalize()}var E=!!process.stdout.isTTY&&process.env.NO_COLOR===void 0;function T(e){let i=new Set;for(let t of e.operationsByMethod.values())for(let r of t)for(let o of r.servers)i.add(o.rawUrl);return Array.from(i).sort()}function I(e,i,t){let r=e.totalExchanges-e.skippedExchanges;if(r===0&&e.skippedExchanges>0){a.warn(`All ${e.skippedExchanges} exchange(s) were outside the --server "${t}" and were skipped. Check that the server matches the traffic URLs.
9
- `);return}if(e.documentedExchanges>0||r===0)return;let o=T(i),n=t?`Check that the --server "${t}" matches the traffic URLs and that the description paths align with the remainder.`:e.hostCompatibleExchanges===r?`The traffic hosts are compatible with the description servers (${o.join(", ")}), so the endpoints are likely undocumented; if they should be documented, check that the description base paths and paths align with the traffic URLs, or use --server to declare the server the traffic was captured against.`:`Check that the traffic host and base path match the description servers (${o.join(", ")}), or use --server to declare the server the traffic was captured against.`;a.warn(`None of the ${r} validated exchange(s) matched a documented operation. ${n}
10
- `)}async function $(e,i){let t=f(e);await S(C.dirname(t),{recursive:!0}),await O(t,i,"utf8")}async function q({argv:e,config:i}){let t=f(e.traffic),r=e["traffic-format"],o=e.rules?u(e.rules):void 0,n=e["ignore-headers"]?u(e["ignore-headers"]):void 0,s=e.server;if(s&&e["match-mode"])throw new m("The --server and --match-mode options are mutually exclusive: --match-mode controls how requests are located via the description servers, while --server replaces the description servers with the one the traffic was captured against.");let c=e["match-mode"]??"strict-host",d=f(e.api),p=await R(d,i);if(p.loadedOperations===0)throw new m(`No OpenAPI operations were loaded from: ${d}`);let{runId:k,summary:h,findings:A}=await F({trafficPath:t,format:r,matchMode:c,ignoreCookies:e["ignore-cookies"],ignoreHeaders:n,previewFindingsLimit:e["max-findings"],activeRules:o,openApiIndex:p,server:s,minSeverity:e["min-severity"]});I(h,p,s);let l=x({runId:k,summary:h,findings:A,meta:{specSource:d,trafficPath:t,format:r,matchMode:c,server:s}},{format:e["report-format"],color:E&&e["report-format"]==="pretty"&&!e.output,maxFindings:e["max-findings"]});if(e.output?(await $(e.output,l),a.info(`Drift report written to: ${f(e.output)}
11
- `)):a.output(l),h.findingsBySeverity.error>0)throw new w("Drift detected.")}export{q as handleDrift};
@@ -1,45 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{$,C as V,D as F,E as _,H as U,O as B,P as j,Q as K,R as l,V as u,X as o,ca as a,d as Y,da as J,e as S,f as G,ga as M,ja as I,ka as C,l as c,ma as q,pa as H,t as d}from"./M4YE5ALG.js";import{performance as be}from"perf_hooks";function X(e){return e?._?.[0]??""}import*as p from"node:fs";import{basename as Q,dirname as A,extname as h,join as Z,resolve as y,relative as ce}from"node:path";import*as f from"node:process";import{performance as fe}from"perf_hooks";var O=["json","yaml","yml"];async function re(e,n){let t=!S(e)&&G(n.resolvedConfig.apis)?me(n):await ue(e,n),s=t.filter(({path:i})=>!le(i));if(S(s)){for(let{path:i}of s)o.warn(`
8
- ${v(i)} ${B(`does not exist or is invalid.
9
-
10
- `)}`);throw new a("Please provide a valid path.")}if(t.length===0)throw new a("No APIs were provided. Specify an API via the command argument or define one in your config.");return t}function T(e){return e.configPath?A(e.configPath):f.cwd()}function le(e){if(!e.trim())throw new a("Path cannot be empty.");return p.existsSync(e)||d(e)?e:void 0}function me(e){return Object.entries(e.resolvedConfig.apis||{}).map(([n,{root:r,output:t}])=>({path:d(r)?r:y(T(e),r),alias:n,output:t&&y(T(e),t)}))}function ee(e,n){let r=T(e),t=e.resolvedConfig.apis?.[n];return t?{path:d(t.root)?t.root:y(r,t.root),alias:n,output:t.output&&y(r,t.output)}:{path:n,alias:Object.entries(e.resolvedConfig.apis||{}).find(([s,i])=>y(r,i.root)===y(n))?.[0]??void 0}}async function ue(e,n){let{hasMagic:r,glob:t}=await import("./SJHPKWSD.js");return(await Promise.all(e.map(async s=>r(s)&&!d(s)?(await t(s,{cwd:T(n)})).map(w=>ee(n,w)):ee(n,s)))).flat()}function R(e){return f.env.NODE_ENV==="test"?"<test>ms":`${Math.ceil(fe.now()-e)}ms`}function ke(e,n,r){let t=R(n);o.info(u(`
11
- ${r}: ${e} processed in ${t}
12
-
13
- `))}function Ne(e,n){return e==="/"?n:e.replaceAll("~1","/").replaceAll("~0","~").replace(/^\//,"").replaceAll("/",n)}function Se(e){return e.replace(/#/g,"_sharp").replace(/\//,"_").replace(/\s/g,"")}function Fe(e){return{php:".php","c#":".cs",shell:".sh",curl:".sh",bash:".sh",javascript:".js",js:".js",python:".py",c:".c","c++":".cpp",coffeescript:".litcoffee",dart:".dart",elixir:".ex",go:".go",groovy:".groovy",java:".java",kotlin:".kt","objective-c":".m",perl:".pl",powershell:".ps1",ruby:".rb",rust:".rs",scala:".sc",swift:".swift",typescript:".ts",tsx:".tsx","visual basic":".vb","c/al":".al"}[e.toLowerCase()]??""}var P=class e extends Error{constructor(r){super(r.message);this.originalError=r;Object.setPrototypeOf(this,e.prototype)}originalError};function Ie(e,n,r){if(n==="json")try{return JSON.stringify(e,null,2)}catch(t){throw t.message.indexOf("circular")>-1?new P(t):t}else return F(e,{noRefs:!r,lineWidth:-1})}function Re(e,n){p.mkdirSync(A(e),{recursive:!0}),p.writeFileSync(e,n)}function Le(e){return V(p.readFileSync(e,"utf-8"),{filename:e})}function ze(e,n,r){if(ye(n)==="json"){de(e,n);return}ge(e,n,r)}function ge(e,n,r=!1){let t=F(e,{noRefs:r});if(f.env.NODE_ENV==="test"){o.info(t);return}p.mkdirSync(A(n),{recursive:!0}),p.writeFileSync(n,t)}function de(e,n){let r=JSON.stringify(e,null,2);if(f.env.NODE_ENV==="test"){o.info(r);return}p.mkdirSync(A(n),{recursive:!0}),p.writeFileSync(n,r)}function ye(e){let n=e.split(".").pop();return O.includes(n)?n:(o.warn(`Unsupported file extension: ${n}. Using yaml.
14
- `),"yaml")}function L(e,n){switch(e.constructor){case a:throw e;case U:throw new a(`Failed to resolve API description at ${n}:
15
-
16
- - ${e.message}`);case _:throw new a(`Failed to parse API description at ${n}:
17
-
18
- - ${e.message}`);case P:throw new a(`Detected circular reference which can't be converted to JSON.
19
- Try to use ${l("yaml")} output or remove ${l("--dereferenced")}.`);case SyntaxError:throw new a(`Syntax error: ${e.message} ${e.stack?.split(`
20
-
21
- `)?.[0]}`);case $:throw new a(e.message);default:throw new a(`Something went wrong when processing ${n}:
22
-
23
- - ${e.message}`)}}function te(e,n){let r=e.ignored?K(`${e.ignored} ${c("problem is",e.ignored)} explicitly ignored.
24
-
25
- `):"";e.errors>0?o.error(`\u274C Validation failed with ${e.errors} ${c("error",e.errors)}${e.warnings>0?` and ${e.warnings} ${c("warning",e.warnings)}`:""}.
26
- ${r}`):e.warnings>0?(o.info(j(`Woohoo! Your API ${c("description is",n)} valid. \u{1F389}
27
- `)),o.warn(`You have ${e.warnings} ${c("warning",e.warnings)}.
28
- ${r}`)):o.info(j(`Woohoo! Your API ${c("description is",n)} valid. \u{1F389}
29
- ${r}`)),e.errors>0&&o.info(u("run `redocly lint --generate-ignore-file` to add all problems to the ignore file.\n")),o.info(`
30
- `)}function oe(e,n){e.errors>0?o.error(`\u274C Your config has ${e.errors} ${c("error",e.errors)}.
31
- `):e.warnings>0?o.warn(`\u26A0\uFE0F Your config has ${e.warnings} ${c("warning",e.warnings)}.
32
- `):n==="check-config"&&o.info(j(`\u2705 Your config is valid.
33
- `))}function We({entrypoint:e,output:n,argvOutput:r,ext:t,entries:s}){let i=n||r;if(!i)return{ext:t||"yaml"};if(s>1&&r){if(t=t||h(e).substring(1),!O.includes(t))throw new Error(`Invalid file extension: ${t}.`);i=Z(r,Q(e,h(e)))+"."+t}else{if(t=t||h(i).substring(1)||h(e).substring(1),!O.includes(t))throw new Error(`Invalid file extension: ${t}.`);i=Z(A(i),Q(i,h(i)))+"."+t}return{outputFile:i,ext:t}}function ie(e){let{preprocessors:n,rules:r,decorators:t}=e.getUnusedRules();r.length&&o.warn(`[WARNING] Unused rules found in ${l(e.configPath||"")}: ${r.join(", ")}.
34
- `),n.length&&o.warn(`[WARNING] Unused preprocessors found in ${l(e.configPath||"")}: ${n.join(", ")}.
35
- `),t.length&&o.warn(`[WARNING] Unused decorators found in ${l(e.configPath||"")}: ${t.join(", ")}.
36
- `),(r.length||n.length)&&o.warn(`Check the spelling and verify the added plugin prefix.
37
- `)}async function Ye(e,n){try{let r=await M({configPath:e.config,customExtends:e.extends});return await ne(e,n,r),r}catch(r){L(r,"")}}function we(e){return e.asyncapi?.startsWith("2")}var xe=["swagger","info","host","basePath","schemes","consumes","produces","security","tags","externalDocs","paths","definitions","parameters","responses","securityDefinitions"],he=["openapi","info","jsonSchemaDialect","servers","security","tags","externalDocs","paths","webhooks","x-webhooks","components"],Ae=["asyncapi","id","info","externalDocs","tags","defaultContentType","servers","channels","components"],ve=["asyncapi","info","defaultContentType","servers","channels","operations","components"];function Ge(e){return"asyncapi"in e?we(e)?D(e,Ae):D(e,ve):"swagger"in e?D(e,xe):D(e,he)}function D(e,n){let r={};for(let t of n)e.hasOwnProperty(t)&&(r[t]=e[t]);return Object.assign(r,e)}function se(e){let n={...e.oas2,...e.oas3_0,...e.oas3_1,...e.oas3_2,...e.async2,...e.async3,...e.arazzo1,...e.overlay1,...e.openrpc1,...e.graphql};if(Y(n))throw new a("\u26A0\uFE0F No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/")}function Ve(e){return e.replace(/\x1b\[\d+m/g,"")}function v(e){return d(e)?e:ce(f.cwd(),e)}async function qe({argv:e,config:n,version:r,collectSpecData:t,collectResults:s}){let i=await re(e.apis,n),m={errors:0,warnings:0,ignored:0},w=0,z=e.format==="checkstyle"||e.format==="junit",W=[];for(let{path:g,alias:k}of i)try{let N=be.now(),b=n.forAlias(k);se(b.rules),b.skipRules(e["skip-rule"]),b.skipPreprocessors(e["skip-preprocessor"]),typeof n.document?.parsed>"u"&&!e.extends&&o.info(`No configurations were provided -- using built in ${l("recommended")} configuration by default.
38
-
39
- `),k===void 0?o.info(u(`validating ${v(g)}...
40
- `)):o.info(u(`validating ${v(g)} using lint rules for api '${k}'...
41
- `));let x=await q({ref:g,config:b,collectSpecData:t});s?.(x);let E=I(x);if(m.errors+=E.errors,m.warnings+=E.warnings,m.ignored+=E.ignored,e["generate-ignore-file"]){n.clearIgnoreForRef(g);for(let pe of x)n.addIgnore(pe),w++}else z?W.push(...x):C(x,{format:e.format,maxProblems:e["max-problems"],totals:E,version:r,command:"lint"});let ae=R(N);o.info(u(`${v(g)}: validated in ${ae}
42
-
43
- `))}catch(N){L(N,g)}if(z&&!e["generate-ignore-file"]&&C(W,{format:e.format,maxProblems:e["max-problems"],totals:m,version:r,command:"lint"}),e["generate-ignore-file"]?(n.saveIgnore(),o.info(`Explicitly ignored ${w} ${c("problem",w)}.
44
-
45
- `)):te(m,i.length),ie(n),!(m.errors===0||e["generate-ignore-file"]))throw new J("Lint failed.")}async function ne(e,n,r){if(e["lint-config"]==="off"||r.document===void 0||e.format==="json"||e.format==="junit"||e.format==="checkstyle")return;let t=e?X(e):void 0,s=await H({config:r,severity:e["lint-config"]||"warn"}),i=I(s);if(C(s,{format:e.format,maxProblems:e["max-problems"],totals:i,version:n,command:"check-config"}),oe(i,t),i.errors>0)throw new $}export{O as a,qe as b,ne as c,re as d,T as e,ee as f,R as g,ke as h,Ne as i,Se as j,Fe as k,Ie as l,Re as m,Le as n,ze as o,ye as p,L as q,We as r,ie as s,Ye as t,Ge as u,Ve as v,v as w};
@@ -1,22 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a as oe,e as ae,f as ue,g as ce,h as b,i as de,k as H,l as V,m as pe,n as le,v as he,w as me}from"./WKCOTH3C.js";import{I as X,L as Je,M as Z,N as g,O,P as ee,Q as $,R as C,T as S,V as y,X as w,Y as te,Z as ne,_ as re,aa as se,c as l,fa as ie,q as Y,v as Q,y as We}from"./M4YE5ALG.js";import{e as J}from"./RFWIIJFG.js";import fe from"node:path";function R(t){return t?t.trim():""}function T(t){let e=R(t.operationId)||R(t.path);return[R(t.ruleId),R(t.severity),R(t.message),e,R(t.target),R(t.schemaPath)].join("")}var F=t=>Z(S(t));function Ye(t){return t==="error"?"error":t==="warning"?"warning":"note"}function Qe(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
8
- `)?e:`"${e.replace(/"/g,'""')}"`}function Xe(t){return fe.isAbsolute(t)?fe.relative(process.cwd(),t)||".":t}function Ze(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function et(t){return Object.entries(t).sort((e,r)=>{let n=r[1]-e[1];return n!==0?n:e[0].localeCompare(r[0])})}function tt(t){let e=[],r=new Map;for(let n of t){let s=T({ruleId:n.ruleId,severity:n.severity,message:n.message,operationId:n.operationId,path:n.path,target:n.target,schemaPath:n.schemaPath}),i=r.get(s);if(i!==void 0){e[i].occurrences+=1;continue}r.set(s,e.length),e.push({finding:n,occurrences:1})}return e}function nt(t){let e=tt(t.findings).map(n=>({occurrences:n.occurrences,exchangeIndex:n.finding.exchangeIndex,ruleId:n.finding.ruleId,severity:n.finding.severity,category:n.finding.category,message:n.finding.message,operationId:n.finding.operationId,specSource:n.finding.specSource,target:n.finding.target,schemaPath:n.finding.schemaPath,dataPath:n.finding.dataPath,details:n.finding.details,method:n.finding.method,url:n.finding.url,path:n.finding.path,status:n.finding.status})),r={run:{id:t.runId,specSource:t.meta.specSource,trafficPath:t.meta.trafficPath,format:t.meta.format,matchMode:t.meta.matchMode,server:t.meta.server,totalExchanges:t.summary.totalExchanges,documentedExchanges:t.summary.documentedExchanges,undocumentedExchanges:t.summary.undocumentedExchanges,skippedExchanges:t.summary.skippedExchanges,findingsBySeverity:t.summary.findingsBySeverity,findingsByRule:t.summary.findingsByRule,totalProblems:t.summary.totalProblemGroups,durationMs:t.summary.durationMs},problems:e};return`${JSON.stringify(r,null,2)}
9
- `}function rt(t){let e=["run_id","finding_id","exchange_index","severity","category","rule_id","message","method","path","url","status","operation_id","spec_source","target","schema_path","data_path"],r=t.findings.map(s=>[t.runId,s.id,s.exchangeIndex,s.severity,s.category,s.ruleId,s.message,s.method,s.path,s.url,s.status,s.operationId,s.specSource,s.target,s.schemaPath,s.dataPath]);return`${[e,...r].map(s=>s.map(Qe).join(",")).join(`
10
- `)}
11
- `}function st(t){let e=new Map;for(let s of t.findings)e.has(s.ruleId)||e.set(s.ruleId,{id:s.ruleId,name:s.ruleId,shortDescription:{text:`${s.category} detection`}});let r=t.findings.map(s=>{let i=s.specSource??s.url??void 0;return{ruleId:s.ruleId,level:Ye(s.severity),message:{text:s.message},locations:i?[{physicalLocation:{artifactLocation:{uri:i}}}]:void 0,properties:{runId:t.runId,exchangeIndex:s.exchangeIndex,method:s.method,path:s.path,status:s.status,operationId:s.operationId,target:s.target,schemaPath:s.schemaPath,dataPath:s.dataPath}}}),n={$schema:"https://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[{tool:{driver:{name:"drift",rules:Array.from(e.values())}},results:r}]};return`${JSON.stringify(n,null,2)}
12
- `}function it(t){return t.findingsBySeverity.error+t.findingsBySeverity.warning+t.findingsBySeverity.info}function ot(t){return t>=500?O:t>=400?$:t>=300?C:t>=200?ee:y}function at(t,e,r){let n=(h,f)=>e?f(h):h,s=h=>h==="error"?n("\u2716",O):h==="warning"?n("\u25B2",$):n("\u25CF",C),i=h=>h==="error"?n("ERROR",O):h==="warning"?n("WARN",$):n("INFO",C),{summary:o,meta:a}=t,c=it(o),p=o.previewFindings.slice(0,r),u=[];if(u.push(n("\u250F\u2501 Drift Report",F)),u.push(`\u2503 Run: ${t.runId}`),u.push(`\u2503 Spec: ${a.specSource}`),u.push(`\u2503 Traffic: ${a.trafficPath}`),u.push(a.server?`\u2503 Server: ${a.server} (overrides description servers)`:`\u2503 Match mode: ${a.matchMode}`),u.push(`\u2503 Traffic format: ${a.format}${a.format==="auto"?" (auto-detect)":""}`),u.push(`\u2503 Exchanges: total=${o.totalExchanges} documented=${o.documentedExchanges} undocumented=${o.undocumentedExchanges}${o.skippedExchanges>0?` skipped=${o.skippedExchanges}`:""}`),u.push(`\u2503 Findings: total=${c} ${n(`error=${o.findingsBySeverity.error}`,O)} ${n(`warning=${o.findingsBySeverity.warning}`,$)} ${n(`info=${o.findingsBySeverity.info}`,C)}`),u.push(`\u2503 Problems: total=${o.totalProblemGroups}`),u.push(`\u2517 Duration: ${o.durationMs}ms`),c===0)return u.push(""),u.push(n("\u2714 No findings.",S)),`${u.join(`
13
- `)}
14
- `;u.push(""),u.push(n(`Types (${Object.keys(o.problemGroupsByRule).length})`,F));for(let[h,f]of et(o.problemGroupsByRule)){let v=o.findingsByRule[h]??f;u.push(` ${n("\u2022",y)} ${h}: ${f} problems / ${v} findings`)}let m=new Map;for(let h of p)m.has(h.ruleId)||m.set(h.ruleId,[]),m.get(h.ruleId).push(h);let x=Array.from(m.keys()).sort((h,f)=>{let v=(o.problemGroupsByRule[f]??0)-(o.problemGroupsByRule[h]??0);return v!==0?v:h.localeCompare(f)});u.push(""),u.push(n(`Problems by type (showing first ${p.length} of ${o.totalProblemGroups})`,F));let q=0;for(let h of x){let f=m.get(h);if(!f||f.length===0)continue;let v=o.problemGroupsByRule[h]??f.length,ze=o.findingsByRule[h]??v;u.push(""),u.push(`${n("\u25C9",S)} ${n(h,F)} ${n(`(${f.length} problems shown / ${v} total, ${ze} findings)`,y)}`);for(let d of f){q+=1;let U=d.occurrences,De=d.status!==void 0?n(String(d.status),ot(d.status)):n("-",y),Ke=Ze(d.details)??d.path,Ue=d.operationId?` ${n(d.operationId,g)}`:"";if(u.push(`${s(d.severity)} ${i(d.severity)} #${q}${U>1?` ${n(`\xD7${U}`,y)}`:""} ${n("\u2192",y)} ${d.message}`),u.push(` \u21B3 sample exchange=${d.exchangeIndex} ${n(d.method,S)} ${Ke} (${De})${Ue}`),u.push(""),u.push(` ${n(d.url,y)}`),(d.specSource||d.schemaPath||d.dataPath)&&(u.push(""),d.specSource&&u.push(` ${n("spec:",g)} ${n(Xe(d.specSource),S)}`),d.schemaPath&&u.push(` ${n("schemaPath=",g)} ${n(d.schemaPath,g)}`),d.dataPath&&u.push(` ${n("dataPath=",g)} ${n(d.dataPath,S)}`)),d.details)if(u.push(""),d.ruleId==="security-baseline"&&typeof d.details.summary=="string")u.push(` ${n("security:",g)} ${d.details.summary}`);else if(d.ruleId==="owasp-api-top10"&&typeof d.details.summary=="string"){let k=typeof d.details.issueId=="string"?d.details.issueId:null,A=typeof d.details.issueTitle=="string"?d.details.issueTitle:null;u.push(` ${n("owasp:",g)} ${d.details.summary}`),(k||A)&&u.push(` ${n("issue:",g)} ${[k,A].filter(Boolean).join(" - ")}`)}else if(d.ruleId==="schema-consistency"&&typeof d.details.summary=="string"){let k=typeof d.details.path=="string"?d.details.path:null,A=typeof d.details.expected=="string"?d.details.expected:null,G=typeof d.details.actual=="string"?d.details.actual:null,W=typeof d.details.suggestion=="string"?d.details.suggestion:null;if(u.push(` ${n("schema:",g)} ${d.details.summary}`),k&&u.push(` ${n("path:",g)} ${n(k,S)}`),A&&u.push(` ${n("expected:",g)} ${A}`),G&&u.push(` ${n("actual:",g)} ${G}`),W){u.push(` ${n("hint:",g)}`);for(let Ge of W.split(`
15
- `))u.push(` ${Ge}`)}}else u.push(` ${n("details:",g)} ${JSON.stringify(d.details)}`);u.push("")}}let P=o.totalProblemGroups-p.length;return P>0?(u[u.length-1]!==""&&u.push(""),u.push(n(`\u2026 ${P} problems omitted from terminal output. Use --format json/csv/sarif for the complete export.`,y))):u[u.length-1]===""&&u.pop(),`${u.join(`
16
- `)}
17
- `}function Hn(t,e){let r=e.maxFindings??10;switch(e.format){case"json":return nt(t);case"csv":return rt(t);case"sarif":return st(t);case"pretty":return at(t,e.color??!1,r);default:throw new Error(`Unsupported report format: ${e.format}`)}}import{randomUUID as Be}from"node:crypto";function ut(t,e){let r=b(t||"/")||"/",n=b(e.basePath||"/")||"/";return n==="/"?r:r===n?"/":r.startsWith(`${n}/`)?r.slice(n.length)||"/":null}function ct(t,e){return!t.host||!e?!0:t.host===e.toLowerCase()}function dt(t){try{return decodeURIComponent(t)}catch{return t}}function pt(t,e,r){let n=r==="strict-host"?e.host?20:5:0;return t.pathScore*10+n}function ge(t,e){let r={};for(let n=0;n<t.pathParams.length;n+=1){let s=t.pathParams[n],i=e[n+1];s&&i!==void 0&&(r[s]=dt(i))}return r}function lt(t,e){let r=b(e)||"/";for(let n of t){let s=n.pathRegex.exec(r);if(s)return{operation:n,pathParams:ge(n,s)}}return null}function ye(t,e,r,n){let s=e.request.method.toLowerCase(),i=t.operationsByMethod.get(s);if(!i||i.length===0)return null;if(n!==void 0)return lt(i,n);let o=null;for(let a of i)for(let c of a.servers){if(r==="strict-host"&&!ct(c,e.request.host))continue;let p=ut(e.request.path,c);if(!p)continue;let u=a.pathRegex.exec(p);if(!u)continue;let m={score:pt(a,c,r),matched:{operation:a,pathParams:ge(a,u)}};(!o||m.score>o.score)&&(o=m)}return o?.matched??null}var Se=6,ht=2e3,mt=50,ft=5,gt=1e6,yt=/(?:token|api[_-]?key|apikey|password|passwd|secret|authorization|jwt)/i,St=/(?:password|passwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|private[_-]?key|ssn|credit[_-]?card|card[_-]?number|cvv)/i,vt=new Set(["page","limit","offset","cursor","per_page","perpage","size","start","after","before"]),ve=4,wt=ve*2;function Rt(t){return t.length<=wt?"***":`${t.slice(0,ve)}\u2026`}function It(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Pt(t){return typeof t=="string"||typeof t=="number"}function bt(t){let e=t.toLowerCase();return e.includes("secret")||e.includes("token")||e.includes("key")?e.startsWith("is")||e.startsWith("has")||e.startsWith("can")||e.startsWith("should")||e.startsWith("enable")||e.startsWith("allow"):!1}function xt(t){if(typeof t=="number")return t===0||t===1;let e=t.trim().toLowerCase();return e==="true"||e==="false"||e==="0"||e==="1"}function kt(t){if(!l(t)&&!Array.isArray(t))return[];let e=[],r=[{value:t,path:""}],n=0;for(;r.length>0&&n<ht&&e.length<Se;){let s=r.pop();if(!s)break;if(n+=1,Array.isArray(s.value)){let i=Math.min(s.value.length,mt);for(let o=0;o<i;o+=1){let a=s.value[o];(l(a)||Array.isArray(a))&&r.push({value:a,path:`${s.path}/${o}`})}continue}if(l(s.value))for(let[i,o]of Object.entries(s.value)){let a=`${s.path}/${It(i)}`;if(St.test(i)&&Pt(o)){let c=String(o);if(bt(i)&&xt(o))continue;if(c.length>0&&(e.push(a||"/"),e.length>=Se))break}(l(o)||Array.isArray(o))&&r.push({value:o,path:a})}}return e}function At(t){for(let e of t.keys())if(vt.has(e.toLowerCase()))return!0;return!1}function I(t,e,r,n,s){return{ruleId:"owasp-api-top10",severity:n,category:"security",message:e,exchangeIndex:t.exchange.index,operationId:t.matchedOperation?.operation.operationId,specSource:t.matchedOperation?.operation.specSource,target:r,details:s}}function Ot(t){let e=[];for(let[r,n]of t.exchange.request.query.entries())if(yt.test(r)&&(e.push({key:r,valuePreview:Rt(n)}),e.length>=ft))break;return e.length===0?[]:[I(t,"Sensitive credential-like query parameters detected","request","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:"Authentication data should not be passed via query parameters because it can leak via logs, browser history, and referrers.",sensitiveQueryParams:e})]}function $t(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["access-control-allow-origin"]?.trim(),n=e.headers["access-control-allow-credentials"]?.trim().toLowerCase();return r!=="*"||n!=="true"?[]:[I(t,"Insecure CORS policy: wildcard origin with credentials enabled","response","error",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Access-Control-Allow-Origin is "*" while Access-Control-Allow-Credentials is true. Browsers may expose authenticated API responses to untrusted origins.',headers:{accessControlAllowOrigin:r,accessControlAllowCredentials:n}})]}function Ct(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["set-cookie"];if(!r)return[];let n=[];for(let s of ue(r)){let i=new Set(s.split(";").slice(1).map(o=>o.split("=")[0].trim().toLowerCase()));t.exchange.request.protocol==="https:"&&!i.has("secure")&&n.push(I(t,'Set-Cookie header is missing "Secure" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies over HTTPS should include "Secure" to prevent transmission over plain HTTP.',setCookiePreview:s.slice(0,200)})),i.has("httponly")||n.push(I(t,'Set-Cookie header is missing "HttpOnly" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies should include "HttpOnly" to reduce risk of token theft via client-side script access.',setCookiePreview:s.slice(0,200)})),i.has("samesite")||n.push(I(t,'Set-Cookie header is missing "SameSite" attribute',"response","info",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Set "SameSite" on session cookies to reduce CSRF risk for state-changing requests.',setCookiePreview:s.slice(0,200)}))}return n}function Et(t){let e=t.exchange.response;if(!e||e.bodyJson===void 0)return[];let r=kt(e.bodyJson);return r.length===0?[]:[I(t,"Potential sensitive data exposure in response payload","response","warning",{issueId:"API3:2019",issueTitle:"Excessive Data Exposure",summary:`Sensitive-looking fields detected in response payload: ${r.join(", ")}`,exposedPaths:r})]}function qt(t){let e=t.exchange.response;return!e||e.status>=400||t.exchange.request.method!=="GET"?[]:!e.bodyText||e.bodyText.length<gt?[]:At(t.exchange.request.query)?[]:[I(t,"Large response without pagination parameters (possible resource-consumption risk)","response","info",{issueId:"API4:2023",issueTitle:"Unrestricted Resource Consumption",summary:"A large response was returned without common pagination query parameters. Consider explicit page/limit controls for large collections.",responseBytes:e.bodyText.length})]}var M=class{id="owasp-api-top10";analyze(e){return e.matchedOperation?[...Ot(e),...$t(e),...Ct(e),...Et(e),...qt(e)]:[]}};var we=200;function Re(t){return t!==void 0&&t!==""}function Tt(t){if(!t)return{};let e={};for(let r of t.split(";")){let[n,...s]=r.trim().split("=");if(!n)continue;let i=s.join("=").trim();e[n]=i}return e}function Ft(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Mt(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function jt(t){return!t||t==="#"?"":t.startsWith("#")?t.slice(1):t}function N(t){let e=jt(t);return!e||e==="/"?[]:e.split("/").slice(1).map(r=>Ft(r))}function Ie(t,e){return`/${[...N(t),Mt(e)].join("/")}`}function Bt(t,e){let r=N(e),n=t;for(let s of r){if(Array.isArray(n)){let i=Number.parseInt(s,10);if(!Number.isInteger(i)||i<0||i>=n.length)return;n=n[i];continue}if(!l(n))return;n=n[s]}return n}function z(t){let e=t.instancePath??"",r=t.params??{};return t.keyword==="required"&&typeof r.missingProperty=="string"?Ie(e,r.missingProperty):t.keyword==="additionalProperties"&&typeof r.additionalProperty=="string"?Ie(e,r.additionalProperty):e}function Lt(t){let e=N(t);if(e.length===0)return"root";let r=[];for(let n of e)/^\d+$/.test(n)?r.push(`[${n}]`):r.length===0?r.push(n):r.push(`.${n}`);return r.join("")}function _t(t){if(t===void 0)return"[missing]";let e=JSON.stringify(t);return e?e.length>we?`${e.slice(0,we)}\u2026`:e:String(t)}function Ht(t){let e=t.params??{};if(t.keyword==="required"&&typeof e.missingProperty=="string")return`required field "${e.missingProperty}"`;if(t.keyword==="type"&&typeof e.type=="string")return`type "${e.type}"`;if(t.keyword==="additionalProperties")return"no additional undocumented properties";if(t.keyword==="format"&&typeof e.format=="string")return`format "${e.format}"`}function Vt(t,e,r){let n=t==="request"?"Request":"Response",s=e.params??{},i=Lt(r);return e.keyword==="required"&&typeof s.missingProperty=="string"?`${n} is missing required field "${i}".`:e.keyword==="additionalProperties"&&typeof s.additionalProperty=="string"?`${n} has undocumented field "${i}".`:e.keyword==="type"&&typeof s.type=="string"?`${n} field "${i}" must be ${s.type}.`:e.keyword==="enum"?`${n} field "${i}" has a value outside allowed enum values.`:e.keyword==="format"&&typeof s.format=="string"?`${n} field "${i}" does not match format "${s.format}".`:`${n} schema mismatch at "${i}": ${e.message??"validation error"}`}function be(t,e,r){let n=z(e),s=Bt(t,n);return{summary:Vt(r,e,n),keyword:e.keyword??null,path:n||"/",expected:Ht(e)??null,actual:_t(s),suggestion:null,params:e.params??{},ajvMessage:e.message??"validation error"}}function Nt(t,e,r,n){if(e==null||!t.schema)return;let s=r.validateSchema(t.schema,e,{coerce:!0});if(!s.valid)for(let i of s.errors){let o=be(e,i,"request");n.push({ruleId:"schema-consistency",severity:"error",category:"schema",message:`Invalid ${t.in} parameter "${t.name}": ${typeof o.summary=="string"?o.summary:i.message??"schema mismatch"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:"request",schemaPath:i.schemaPath,dataPath:z(i),details:{...o,parameter:{name:t.name,in:t.in}}})}}var zt=/^([^[\]]+)\[([^[\]]+)\]$/;function xe(t){let e=t.match(zt);return e?{parameterName:e[1],property:e[2]}:void 0}function Dt(t,e){let r;for(let[n,s]of e){let i=xe(n);i?.parameterName===t&&(r??={},r[i.property]=s)}return r}function Kt(t,e,r){switch(t.in){case"path":return e.matchedOperation?.pathParams[t.name];case"query":{if(t.style==="deepObject")return Dt(t.name,e.exchange.request.query);let n=e.exchange.request.query.getAll(t.name);return n.length===0?void 0:(l(t.schema)?t.schema.type:void 0)==="array"||n.length>1?n:n[0]}case"header":return e.exchange.request.headers[t.name.toLowerCase()];case"cookie":return r[t.name];default:return}}function Ut(t,e){let r=[],n={query:new Set,header:new Set,cookie:new Set},s=new Set;for(let i of e.operation.requestParameters)i.in==="header"?n.header.add(i.name.toLowerCase()):(i.in==="query"||i.in==="cookie")&&(n[i.in].add(i.name),i.in==="query"&&i.style==="deepObject"&&s.add(i.name));for(let i of new Set(t.exchange.request.query.keys())){if(n.query.has(i))continue;let o=xe(i);o&&s.has(o.parameterName)||r.push({ruleId:"schema-consistency",severity:"warning",category:"documentation",message:`Undocumented query parameter in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"})}for(let i of Object.keys(t.exchange.request.headers))le(i,t.ignoreHeaders)||n.header.has(i.toLowerCase())||r.push({ruleId:"schema-consistency",severity:"info",category:"documentation",message:`Undocumented header in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"});return r}function Gt(t){let e=t.exchange.response;return e!==void 0&&e.status>=400&&e.status<500}function Wt(t,e){let r=t.exchange.response;if(!r)return;let n=String(r.status),s=`${Math.floor(r.status/100)}XX`,i=e.operation.responseBodyContent[n]??e.operation.responseBodyContent[s]??e.operation.responseBodyContent[s.toLowerCase()]??e.operation.responseBodyContent.default;if(i)return V(i,r.contentType)}function Pe(t,e,r,n){let s=r.validateSchema(t,e,{target:n});return s.valid?[]:s.errors.map(i=>{let o=be(e,i,n);return{ruleId:"schema-consistency",severity:"error",category:"schema",message:typeof o.summary=="string"?o.summary:`Schema mismatch (${n}): ${i.message??"validation error"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:n,schemaPath:i.schemaPath,dataPath:z(i),details:o}})}var j=class{id="schema-consistency";analyze(e){let r=e.matchedOperation;if(!r)return[];let n=[],s=Tt(e.exchange.request.headers.cookie);if(n.push(...Ut(e,r)),!Gt(e)){for(let p of r.operation.requestParameters){if(e.ignoreCookies&&p.in==="cookie")continue;let u=Kt(p,e,s);if(p.required&&u==null){n.push({ruleId:this.id,severity:"error",category:"documentation",message:`Missing required ${p.in} parameter: "${p.name}"`,exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"});continue}Nt(p,u,e,n)}let o=e.exchange.request.contentType,a=V(r.operation.requestBodyContent,o),c=Re(e.exchange.request.bodyText);r.operation.requestBodyRequired&&!c&&n.push({ruleId:this.id,severity:"error",category:"documentation",message:"Missing required request body",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}),a&&c&&H(o)&&(e.exchange.request.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Request body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}):n.push(...Pe(a,e.exchange.request.bodyJson,e,"request")))}let i=Wt(e,r);if(i&&e.exchange.response&&Re(e.exchange.response.bodyText)){let o=e.exchange.response.contentType;H(o)&&(e.exchange.response.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Response body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"response"}):n.push(...Pe(i,e.exchange.response.bodyJson,e,"response")))}return n}};function D(t){if(!t)return null;let[e]=t.trim().split(/\s+/,1);return e?e.toLowerCase():null}function Ae(t){return!!t.exchange.request.headers.authorization}function Jt(t,e){return t?t.split(";").map(r=>r.trim()).some(r=>r.startsWith(`${e}=`)):!1}function Yt(t,e){let r=t.matchedOperation?.operation;if(!r)return{schemeName:e,schemeType:"unknown",satisfied:!0,reason:"No matched OpenAPI operation."};let n=r.securitySchemes[e];if(!n)return{schemeName:e,schemeType:"missing",satisfied:!1,reason:"Security scheme is referenced but not defined in components.securitySchemes."};let s=String(n.type??"unknown");if(n.type==="apiKey"){let i=String(n.name??""),o=String(n.in??"header");if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:'apiKey scheme is missing the "name" field in the OpenAPI spec.'};if(o==="header"){let a=!!t.exchange.request.headers[i.toLowerCase()];return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey header "${i}".`:`Missing required apiKey header "${i}".`}}if(o==="query"){let a=t.exchange.request.query.has(i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey query parameter "${i}".`:`Missing required apiKey query parameter "${i}".`}}if(o==="cookie"){if(t.ignoreCookies)return{schemeName:e,schemeType:s,satisfied:!0,skipped:!0,reason:`Skipped apiKey cookie "${i}" validation because --ignore-cookies is enabled.`};let a=Jt(t.exchange.request.headers.cookie,i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey cookie "${i}".`:`Missing required apiKey cookie "${i}".`}}return{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported apiKey location "${o}" in OpenAPI security scheme.`}}if(n.type==="http"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header."};let o=String(n.scheme??"").toLowerCase(),a=D(i);if(!o)return{schemeName:e,schemeType:s,satisfied:!0,reason:"Authorization header is present and no specific HTTP auth scheme is documented."};if(!a)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Authorization header is malformed and does not include an auth scheme."};let c=a===o;return{schemeName:e,schemeType:s,satisfied:c,reason:c?`Authorization uses expected "${o}" scheme.`:`Authorization uses "${a}" but "${o}" is required.`}}if(n.type==="oauth2"||n.type==="openIdConnect"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header for OAuth2/OpenID Connect scheme."};let o=D(i),a=o==="bearer";return{schemeName:e,schemeType:s,satisfied:a,reason:a?"Authorization uses bearer token as expected for OAuth2/OpenID Connect.":`Authorization scheme "${o??"unknown"}" does not satisfy OAuth2/OpenID Connect (expected bearer).`}}return n.type==="mutualTLS"?{schemeName:e,schemeType:s,satisfied:!0,reason:"mutualTLS cannot be validated from HTTP traffic logs alone."}:{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported security scheme type "${s}".`}}function Qt(t){let e=t.matchedOperation?.operation.security;if(!e)return{satisfied:!0,requirements:[]};if(e.length===0)return{satisfied:!0,requirements:[]};let r=e.map((n,s)=>{let i=Object.keys(n);if(i.length===0)return{requirementIndex:s,satisfied:!0,schemeResults:[]};let o=i.map(a=>Yt(t,a));return{requirementIndex:s,satisfied:o.every(a=>a.satisfied),schemeResults:o}});return{satisfied:r.some(n=>n.satisfied),requirements:r}}function Xt(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.satisfied||e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function ke(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.skipped&&e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function Zt(t){if(t.length===0)return"All documented security requirements are satisfied.";let e=new Map;for(let n of t){let s=e.get(n.requirement);s?s.push(n):e.set(n.requirement,[n])}let r=Array.from(e.entries()).sort((n,s)=>n[0]-s[0]).map(([n,s])=>{let i=s.map(a=>a.schemeName).join(" + "),o=s.map(a=>a.reason).join(" ");return`Option ${n} (${i}): ${o}`});return r.length===1?`Authentication check failed. ${r[0]}`:`None of the documented authentication options matched. Any one of these options would satisfy the OpenAPI security requirements: ${r.join(" | ")}`}function en(t){return Array.from(t.exchange.request.query.keys()).filter(e=>{let r=e.toLowerCase();return r.includes("token")||r.includes("apikey")||r.includes("api_key")||r.includes("access_key")})}var tn=/^(?:(?:.+\.)?localhost|127(?:\.\d{1,3}){3}|::1)$/i;function nn(t){let e;try{e=new URL(t.url).hostname}catch{e=t.host?.replace(/:\d+$/,"")}return e?tn.test(e.replace(/^\[|\]$/g,"")):!1}function rn(t){if(t.exchange.request.protocol!=="http:"||!t.exchange.request.protocolKnown||nn(t.exchange.request))return{flag:!1,hasAuthHeader:!1,sensitiveQueryKeys:[]};let e=Ae(t),r=en(t);return{flag:e||r.length>0,hasAuthHeader:e,sensitiveQueryKeys:r}}var B=class{id="security-baseline";analyze(e){if(!e.matchedOperation)return[];let r=[],n=Qt(e);if(n.satisfied){let i=ke(n);i.length>0&&r.push({ruleId:this.id,severity:"info",category:"security",message:"Some documented cookie-based security checks were skipped",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:i.map(o=>`Skipped option ${o.requirement} (${o.schemeName}): ${o.reason}`).join(" "),skippedChecks:i}})}else{let i=Xt(n);r.push({ruleId:this.id,severity:"error",category:"security",message:"Request does not satisfy documented OpenAPI security requirements",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:Zt(i),failedChecks:i,skippedChecks:ke(n),authorizationScheme:D(e.exchange.request.headers.authorization),hasAuthorizationHeader:Ae(e)}})}let s=rn(e);return s.flag&&r.push({ruleId:this.id,severity:"warning",category:"security",message:"Potential credential exposure over insecure HTTP transport",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{protocol:e.exchange.request.protocol,hasAuthorizationHeader:s.hasAuthHeader,sensitiveQueryKeys:s.sensitiveQueryKeys}}),r}};var L=class{id="undocumented-endpoint";analyze(e){if(e.matchedOperation)return[];let{method:r,path:n,host:s}=e.exchange.request,o=e.matchMode==="strict-host"&&!e.hostCompatibleWithSpecServers?`Undocumented server: ${r} ${n} was sent to "${s}", which does not match any server in the description`:`Undocumented endpoint: ${r} ${n}`;return[{ruleId:this.id,severity:"error",category:"documentation",message:o,exchangeIndex:e.exchange.index,target:"request"}]}};var K={"undocumented-endpoint":()=>new L,"schema-consistency":()=>new j,"security-baseline":()=>new B,"owasp-api-top10":()=>new M},sn=Object.keys(K),on=["undocumented-endpoint","schema-consistency","security-baseline"];function Oe(t){return!t||t.length===0?on.map(e=>K[e]()):[...new Set(t)].map(e=>{let r=K[e];if(!r)throw new Error(`Unknown rule id: "${e}". Available rules: ${sn.join(", ")}`);return r()})}var Ee=J(We(),1);var qe=J(Je(),1),$e=Ee.default,Ce=qe.default;function an(t,e){return l(t)?e==="request"?t.readOnly===!0:t.writeOnly===!0:!1}function Te(t,e,r,n=new WeakSet){if(!l(t)||n.has(t))return!1;n.add(t);let s=t.properties;return l(s)&&an(s[e],r)?!0:[t.allOf,t.oneOf,t.anyOf].some(i=>Array.isArray(i)&&i.some(o=>Te(o,e,r,n)))}var un=new Set(["items","additionalItems","additionalProperties","unevaluatedItems","unevaluatedProperties","contains","propertyNames","not","if","then","else"]),cn=new Set(["allOf","anyOf","oneOf","prefixItems"]),dn=new Set(["properties","patternProperties","dependentSchemas","$defs","definitions"]);function Fe(t,e,r=new WeakSet){if(!l(t))return t;if(r.has(t))return!0;r.add(t);let n=i=>Fe(i,e,r),s={};for(let[i,o]of Object.entries(t))un.has(i)?s[i]=Array.isArray(o)?o.map(n):n(o):cn.has(i)&&Array.isArray(o)?s[i]=o.map(n):dn.has(i)&&l(o)?s[i]=Object.fromEntries(Object.entries(o).map(([a,c])=>[a,n(c)])):s[i]=o;return Array.isArray(t.required)&&(s.required=t.required.filter(i=>typeof i!="string"||!Te(t,i,e))),r.delete(t),s}var E=class{ajv;fallbackAjv;objectSchemaCaches={none:new WeakMap,request:new WeakMap,response:new WeakMap};scalarSchemaCache=new Map;constructor(e){let r={strict:!1,allErrors:!0,allowUnionTypes:!0,discriminator:!0,coerceTypes:e?.coerceTypes?"array":!1,validateFormats:!0,verbose:!0,formats:{enum:!0}};this.ajv=new $e(r),this.fallbackAjv=new $e({...r,discriminator:!1}),Ce(this.ajv),Ce(this.fallbackAjv)}validate(e,r,n){if(e===void 0)return{valid:!0,errors:[]};let s;try{s=this.getOrCompileValidator(e,n)}catch(a){return{valid:!1,errors:[{message:`Schema compilation failed: ${a.message}`}]}}let i=!!s(r),o=s.errors??[];return{valid:i,errors:o}}getOrCompileValidator(e,r){if(l(e)){let o=this.objectSchemaCaches[r??"none"],a=o.get(e);if(a)return a;let c=r?Fe(e,r):e,p=this.compileSchema(c);return o.set(e,p),p}let n=`${r??"none"}:${JSON.stringify(e)}`,s=this.scalarSchemaCache.get(n);if(s)return s;let i=this.compileSchema(e);return this.scalarSchemaCache.set(n,i),i}compileSchema(e){try{return this.ajv.compile(e)}catch{return this.fallbackAjv.compile(e)}}};var pn=10,Me={info:0,warning:1,error:2};function ln(){return{totalExchanges:0,documentedExchanges:0,undocumentedExchanges:0,skippedExchanges:0,hostCompatibleExchanges:0,findingsBySeverity:{info:0,warning:0,error:0},findingsByRule:{}}}function hn(t,e){t.findingsBySeverity[e.severity]+=1,t.findingsByRule[e.ruleId]=(t.findingsByRule[e.ruleId]??0)+1}function mn(t,e){return{...t,id:Be(),method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function fn(t,e){return{exchangeIndex:t.exchangeIndex,ruleId:t.ruleId,severity:t.severity,category:t.category,message:t.message,occurrences:1,operationId:t.operationId,specSource:t.specSource,target:t.target,schemaPath:t.schemaPath,dataPath:t.dataPath,details:t.details,method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function gn(t,e){if(!e)return;t.operationId||(t.operationId=e.operation.operationId),t.specSource||(t.specSource=e.operation.specSource);let r=t.details??{};if(!l(r)){t.details={operationPathTemplate:e.operation.pathTemplate};return}typeof r.operationPathTemplate!="string"&&(r.operationPathTemplate=e.operation.pathTemplate),t.details=r}function yn(t){let e=new Set,r=!1;for(let n of t.operationsByMethod.values())for(let s of n)for(let i of s.servers)i.host?e.add(i.host):r=!0;return{specServerHosts:e,hasHostlessSpecServer:r}}async function Sn(t,e){let r=[];for(let n of t)try{let s=await n.analyze(e);s.length>0&&r.push(...s)}catch(s){w.warn(`Rule "${n.id}" failed to execute: ${s.message}
18
- `)}return r}var je=class t{startedAt=Date.now();runId=Be();previewLimit;rules;schemaValidator=new E;coercingSchemaValidator=new E({coerceTypes:!0});options;counters=ln();findings=[];previewFindings=[];problemGroupsByRule={};problemKeyStats=new Map;totalProblemGroups=0;server;ignoreHeaders;minSeverityRank;specServerHosts;hasHostlessSpecServer;constructor(e,r){this.options=e,this.rules=r,this.server=he(e.server),this.ignoreHeaders=e.ignoreHeaders?pe(e.ignoreHeaders):void 0;let{specServerHosts:n,hasHostlessSpecServer:s}=yn(e.openApiIndex);this.specServerHosts=n,this.hasHostlessSpecServer=s,this.minSeverityRank=Me[e.minSeverity??"info"],this.previewLimit=e.previewFindingsLimit&&e.previewFindingsLimit>0?e.previewFindingsLimit:pn}static create(e){if(e.openApiIndex.loadedOperations===0)throw new Error("No OpenAPI operations available to validate traffic against.");return new t(e,Oe(e.activeRules))}async process(e){this.counters.totalExchanges+=1;let r;if(this.server!==void 0&&(r=me(e.request,this.server),r===void 0))return this.counters.skippedExchanges+=1,[];let n=this.isHostCompatible(e.request.host);n&&(this.counters.hostCompatibleExchanges+=1);let s=ye(this.options.openApiIndex,e,this.options.matchMode,r);s?this.counters.documentedExchanges+=1:this.counters.undocumentedExchanges+=1;let i=await Sn(this.rules,{exchange:e,matchedOperation:s,matchMode:this.options.matchMode,hostCompatibleWithSpecServers:r!==void 0||n,ignoreCookies:this.options.ignoreCookies??!1,ignoreHeaders:this.ignoreHeaders,validateSchema:(a,c,p)=>p?.coerce?this.coercingSchemaValidator.validate(a,c,p?.target):this.schemaValidator.validate(a,c,p?.target)}),o=[];for(let a of i){if(Me[a.severity]<this.minSeverityRank)continue;gn(a,s);let c=mn(a,e);this.findings.push(c),o.push(c),hn(this.counters,a);let p=T({ruleId:a.ruleId,severity:a.severity,message:a.message,operationId:a.operationId,path:e.request.path,target:a.target,schemaPath:a.schemaPath}),u=this.problemKeyStats.get(p);if(u){u.occurrences+=1,u.previewIndex!==null&&(this.previewFindings[u.previewIndex].occurrences=u.occurrences);continue}if(this.totalProblemGroups+=1,this.problemGroupsByRule[a.ruleId]=(this.problemGroupsByRule[a.ruleId]??0)+1,this.previewFindings.length<this.previewLimit){let m=this.previewFindings.length;this.previewFindings.push(fn(a,e)),this.problemKeyStats.set(p,{occurrences:1,previewIndex:m});continue}this.problemKeyStats.set(p,{occurrences:1,previewIndex:null})}return o}isHostCompatible(e){return!e||this.hasHostlessSpecServer||this.specServerHosts.has(e.toLowerCase())}finalize(){let e={runId:this.runId,totalExchanges:this.counters.totalExchanges,documentedExchanges:this.counters.documentedExchanges,undocumentedExchanges:this.counters.undocumentedExchanges,skippedExchanges:this.counters.skippedExchanges,hostCompatibleExchanges:this.counters.hostCompatibleExchanges,findingsBySeverity:this.counters.findingsBySeverity,findingsByRule:this.counters.findingsByRule,problemGroupsByRule:this.problemGroupsByRule,totalProblemGroups:this.totalProblemGroups,durationMs:Date.now()-this.startedAt,previewFindings:this.previewFindings,previewLimit:this.previewLimit,previewTruncated:this.totalProblemGroups>this.previewFindings.length};return{runId:this.runId,summary:e,findings:this.findings}}};import{stat as vn}from"node:fs/promises";function _(t,e){let r=t.replace(/\{([^}]+)\}/g,(i,o)=>{let a=e?.[o];return a?.default!==void 0?String(a.default):Array.isArray(a?.enum)&&a.enum.length>0?String(a.enum[0]):""}),n=ce(r),s=!!(n.host&&!ae(n.host));return{rawUrl:t,protocol:s?n.protocol:void 0,host:s?n.host.toLowerCase():void 0,basePath:b(n.pathname||"/")}}function Le(t){return t?t.startsWith("/")?t:`/${t}`:"/"}var wn=["get","put","post","delete","patch","head","options","trace"],Rn=new Set(["query","header","path","cookie"]);function In(t){return wn.includes(t)}function Pn(t){return Rn.has(t)}function _e(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!l(r))continue;let n=r.in;typeof n!="string"||!Pn(n)||e.push({name:String(r.name??""),in:n,required:!!r.required||n==="path",style:typeof r.style=="string"?r.style:void 0,schema:r.schema})}return e}function He(t){let e=t.in==="header";return`${t.in}:${e?t.name.toLowerCase():t.name}`}function bn(t,e){let r=new Map;for(let n of t)r.set(He(n),n);for(let n of e)r.set(He(n),n);return Array.from(r.values())}function Ne(t){let e={};if(!l(t))return e;for(let[r,n]of Object.entries(t))l(n)&&"schema"in n&&(e[r.toLowerCase()]=n.schema);return e}function xn(t){return l(t)?Ne(t.content):{}}function kn(t){if(!l(t))return{};let e={};for(let[r,n]of Object.entries(t))!l(n)||!("content"in n)||(e[r]=Ne(n.content));return e}function An(t,e,r){let n=t??e??r;return!Array.isArray(n)||n.length===0?[_("/")]:n.map(s=>{if(!l(s))return _("/");let i=typeof s.url=="string"?s.url:"/",o=l(s.variables)?s.variables:void 0;return _(i,o)})}function On(t,e,r){return r||`${t.toUpperCase()} ${e}`}function $n(t){try{let e=ne(t.parsed);return te(e)==="oas3"?e:null}catch{return null}}function Ve(t){return Array.isArray(t)?t:void 0}function Cn(t,e){let r,n,s={},i="/",o=[],a;return{Root:{enter(c){r=c.servers,n=c.security;let p=l(c.components)?c.components.securitySchemes:void 0;s=l(p)?p:{}}},Paths:{PathItem:{enter(c,p){i=Le(String(p.key)),o=_e(c.parameters),a=c.servers},Operation:{enter(c,p){let u=String(p.key);if(!In(u))return;let m=bn(o,_e(c.parameters)),x=de(i),q=An(c.servers,a,r),P=c.requestBody,h={operationId:On(u,i,typeof c.operationId=="string"?c.operationId:void 0),method:u,pathTemplate:i,pathRegex:x.regex,pathParams:x.params,pathScore:x.score,servers:q,requestParameters:m,requestBodyContent:xn(P),requestBodyRequired:l(P)&&!!P.required,responseBodyContent:kn(c.responses),security:Ve(c.security)??Ve(n),securitySchemes:s,specSource:t},f=e.get(u)??[];f.push(h),e.set(u,f)}}}}}}function En(t,e,r,n,s){let i=Y(r.extendTypes(Q(e),e),r),o=new Map,a={problems:[],specVersion:e,config:r,visitorsData:{}},c=re([{severity:"warn",ruleId:"drift-index",visitor:Cn(n,s)}],i);se({document:t,rootType:i.Root,normalizedVisitors:c,resolvedRefMap:o,ctx:a})}function qn(t){return`${t.host??""}|${t.basePath}`}function Tn(t){for(let e of t.values()){let r=new Map;for(let n of e){let s=r.get(n.pathRegex.source)??[];s.push(n),r.set(n.pathRegex.source,s)}for(let n of r.values()){let s=new Map;for(let i of n)for(let o of i.servers){let a=qn(o),c=s.get(a)??new Set;c.add(i.specSource),s.set(a,c)}for(let i of s.values())if(i.size>1){let[o]=n;w.warn(`"${o.method.toUpperCase()} ${o.pathTemplate}" is documented for the same server in multiple descriptions (${Array.from(i).join(", ")}). Matching traffic is validated against only one of them.
19
- `);break}}}}function Fn(t,e){for(let n of t.values())n.sort((s,i)=>i.pathScore-s.pathScore);let r=Array.from(t.values()).reduce((n,s)=>n+s.length,0);return{operationsByMethod:t,loadedSpecs:e,loadedOperations:r}}async function Mn(t){return(await vn(t)).isDirectory()?{specFiles:await oe(t),fromDirectory:!0}:{specFiles:[t],fromDirectory:!1}}async function Rr(t,e){let{specFiles:r,fromDirectory:n}=await Mn(t),s=new Map,i=new X(e.resolve),o=0;for(let a of r){let c=await i.resolveDocument(null,a,!0);if(c instanceof Error){w.warn(`Failed to load OpenAPI description ${a}: ${c.message}
20
- `);continue}let p=$n(c);if(!p){n||w.warn(`Skipping ${a}: not an OpenAPI 3.x description.
21
- `);continue}let u;try{let{bundle:m}=await ie({config:e,doc:c,externalRefResolver:i,dereference:!0});u=m}catch(m){w.warn(`Failed to bundle OpenAPI description ${a}: ${m.message}
22
- `);continue}o+=1,En(u,p,e,a,s)}return o>1&&Tn(s),Fn(s,o)}function Pr(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}export{Hn as a,je as b,Rr as c,Pr as d};
@@ -1,7 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v}from"./OM4VGI2Q.js";import"./LRUXN6H5.js";import"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{j as InvalidReuniteUrlError,f as REUNITE_URLS,l as RedoclyOAuthClient,k as RedoclyOAuthDeviceFlow,c as ReuniteApi,b as ReuniteApiClient,a as ReuniteApiError,n as collectFilesToPush,t as evaluatePluginsFromCode,q as fetchRemoteScorecardAndPlugins,e as getApiKeys,g as getDomain,d as getMostUrgentSunsetWarning,o as getPushStatus,h as getReuniteUrl,s as getTarget,u as isAllowedScorecardProjectUrl,i as isValidReuniteUrl,m as pushFiles,r as resolveConfigForTarget,v as validateScorecard,p as waitForDeployment};
@@ -1,13 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{b as x,c as P,d as c}from"./YUNIBLZR.js";import"./YEACSN2C.js";import{e as y,g as b,m as w,n as $}from"./OM4VGI2Q.js";import"./LRUXN6H5.js";import{h as l}from"./3I7XLHPY.js";import{P as g,X as n,l as p}from"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function C({argv:t,config:o,version:h}){let f=performance.now(),A=Date.now(),{organization:s,project:m,"mount-path":F,verbose:I}=t,d=t.domain||b(),e,r,u=[];try{let i=y();if(e=$(t.files,(a,S)=>{n.warn(`File ${a} is overwritten by ${S}
8
- `)}),!e.length)return l("push",f,"No files to upload");r=(await w({domain:d,apiKey:i,organization:s,project:m,mountPath:F,files:e,defaultBranch:t["default-branch"],commit:{message:t.message,branchName:t.branch,sha:t["commit-sha"],url:t["commit-url"],createdAt:t["created-at"],namespace:t.namespace,repository:t.repository,author:T(t.author)},version:h,replace:t.replace,onUploadStart:a=>{n.info(`Uploading to ${a.mountPath} ${e.length} ${p("file",e.length)}:
9
- `)},onSunsetWarning:a=>u.push(a)})).pushId}catch(i){c("push",u),P("\u2717 File upload failed.",i)}for(let i of e)n.info(g(`\u2713 ${i.name}
10
- `));return n.info(`
11
- `),n.info(`Push ID: ${r}
12
- `),c("push",u),t["wait-for-deployment"]&&(n.info(`
13
- `),await x({argv:{organization:s,project:m,pushId:r,wait:!0,domain:d,"max-execution-time":t["max-execution-time"],"start-time":A,"continue-on-deploy-failures":t["continue-on-deploy-failures"]},config:o,version:h})),I&&l("push",f,`${p("file",e.length)} uploaded to organization ${s}, project ${m}. Push ID: ${r}.`),{pushId:r}}function T(t){let o=t.match(/^(?<name>.+)\s<(?<email>[^<>]+)>$/);if(!o?.groups)throw new Error('Invalid author format. Use "Author Name <author@email.com>"');return{name:o.groups.name.trim(),email:o.groups.email.trim()}}export{C as handlePush};