@preventive/triage 1.0.0-alpha.33 → 1.0.0-alpha.35
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.
- package/client/linked-findings.js +5 -4
- package/common/bundle-metadata.js +4 -3
- package/common/bundle-source-links.d.ts +2 -1
- package/common/bundle-source-links.js +133 -6
- package/common/bundle-sources.d.ts +2 -0
- package/common/bundle-sources.js +2 -4
- package/common/managed/repository-alias.ts +65 -0
- package/common/managed/routes.js +20 -1
- package/common/managed/triage.ts +2 -2
- package/out/client-managed-import.js +51 -46
- package/out/client-managed.js +252 -72
- package/out/client-sync.js +14 -14
- package/out/graph.js +11 -11
- package/out/index.html +1 -0
- package/out/terminal.js +320 -212
- package/out/view.css +1 -1
- package/out/view.js +410 -202
- package/package.json +22 -17
- package/server-managed/activity.ts +15 -1
- package/server-managed/bundle-advisories.ts +8 -3
- package/server-managed/bundle-advisory-inventory.ts +27 -25
- package/server-managed/bundle-build-worker.js +45 -9
- package/server-managed/bundle-build.ts +35 -11
- package/server-managed/bundle-cache.ts +1 -1
- package/server-managed/bundle.ts +17 -1
- package/server-managed/config.ts +5 -0
- package/server-managed/db-methods.ts +168 -49
- package/server-managed/db-neon.ts +59 -4
- package/server-managed/db-schema.ts +12 -3
- package/server-managed/db.ts +9 -1
- package/server-managed/github-issue-links.ts +127 -0
- package/server-managed/github-issues.ts +1 -1
- package/server-managed/http-response.ts +7 -1
- package/server-managed/http.ts +248 -80
- package/server-managed/index.ts +4 -0
- package/server-managed/link-reports.ts +158 -0
- package/server-managed/managed-issues.ts +31 -3
- package/server-managed/management.ts +17 -4
- package/server-managed/public-workspace.ts +5 -2
- package/server-managed/report-sources.ts +6 -5
- package/server-managed/repository-aliases.ts +91 -0
- package/server-managed/revisions.ts +2 -2
- package/server-managed/sql.ts +3 -2
- package/server-managed/storage.ts +17 -0
- package/server-managed/team-feed.ts +3 -3
- package/server-managed/team-reports.ts +24 -15
- package/server-managed/upstream-cache.ts +73 -0
- package/server-managed/workspace-shares.ts +16 -12
|
@@ -1,59 +1,64 @@
|
|
|
1
|
-
var
|
|
2
|
-
\f\r]`,
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Lt=/'/g,Mt=/"/g,Ut=/^(?:script|style|textarea|title)$/i,Ze=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),v=Ze(1),Lo=Ze(2),Mo=Ze(3),S=Symbol.for("lit-noChange"),y=Symbol.for("lit-nothing"),Ot=new WeakMap,O=N.createTreeWalker(N,129);function Dt(t,e){if(!Xe(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ct!==void 0?Ct.createHTML(e):e}var $r=(t,e)=>{let n=t.length-1,i=[],r,o=e===2?"<svg>":e===3?"<math>":"",s=X;for(let a=0;a<n;a++){let c=t[a],l,d,p=-1,u=0;for(;u<c.length&&(s.lastIndex=u,d=s.exec(c),d!==null);)u=s.lastIndex,s===X?d[1]==="!--"?s=Rt:d[1]!==void 0?s=Tt:d[2]!==void 0?(Ut.test(d[2])&&(r=RegExp("</"+d[2],"g")),s=M):d[3]!==void 0&&(s=M):s===M?d[0]===">"?(s=r??X,p=-1):d[1]===void 0?p=-2:(p=s.lastIndex-d[2].length,l=d[1],s=d[3]===void 0?M:d[3]==='"'?Mt:Lt):s===Mt||s===Lt?s=M:s===Rt||s===Tt?s=X:(s=M,r=void 0);let h=s===M&&t[a+1].startsWith("/>")?" ":"";o+=s===X?c+_r:p>=0?(i.push(l),c.slice(0,p)+Nt+c.slice(p)+I+h):c+I+(p===-2?a:h)}return[Dt(t,o+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Y=class t{constructor({strings:e,_$litType$:n},i){let r;this.parts=[];let o=0,s=0,a=e.length-1,c=this.parts,[l,d]=$r(e,n);if(this.el=t.createElement(l,i),O.currentNode=this.el.content,n===2||n===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(r=O.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let p of r.getAttributeNames())if(p.endsWith(Nt)){let u=d[s++],h=r.getAttribute(p).split(I),f=/([.?@])?(.*)/.exec(u);c.push({type:1,index:o,name:f[2],strings:h,ctor:f[1]==="."?je:f[1]==="?"?Ve:f[1]==="@"?Ge:j}),r.removeAttribute(p)}else p.startsWith(I)&&(c.push({type:6,index:o}),r.removeAttribute(p));if(Ut.test(r.tagName)){let p=r.textContent.split(I),u=p.length-1;if(u>0){r.textContent=he?he.emptyScript:"";for(let h=0;h<u;h++)r.append(p[h],Z()),O.nextNode(),c.push({type:2,index:++o});r.append(p[u],Z())}}}else if(r.nodeType===8)if(r.data===Bt)c.push({type:2,index:o});else{let p=-1;for(;(p=r.data.indexOf(I,p+1))!==-1;)c.push({type:7,index:o}),p+=I.length-1}o++}}static createElement(e,n){let i=N.createElement("template");return i.innerHTML=e,i}};function P(t,e,n=t,i){if(e===S)return e;let r=i!==void 0?n._$Co?.[i]:n._$Cl,o=q(e)?void 0:e._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(t),r._$AT(t,n,i)),i!==void 0?(n._$Co??=[])[i]=r:n._$Cl=r),r!==void 0&&(e=P(t,r._$AS(t,e.values),r,i)),e}var Pe=class{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:n},parts:i}=this._$AD,r=(e?.creationScope??N).importNode(n,!0);O.currentNode=r;let o=O.nextNode(),s=0,a=0,c=i[0];for(;c!==void 0;){if(s===c.index){let l;c.type===2?l=new J(o,o.nextSibling,this,e):c.type===1?l=new c.ctor(o,c.name,c.strings,this,e):c.type===6&&(l=new We(o,this,e)),this._$AV.push(l),c=i[++a]}s!==c?.index&&(o=O.nextNode(),s++)}return O.currentNode=N,r}p(e){let n=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,n),n+=i.strings.length-2):i._$AI(e[n])),n++}},J=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,i,r){this.type=2,this._$AH=y,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,n=this._$AM;return n!==void 0&&e?.nodeType===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=P(this,e,n),q(e)?e===y||e==null||e===""?(this._$AH!==y&&this._$AR(),this._$AH=y):e!==this._$AH&&e!==S&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):xr(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==y&&q(this._$AH)?this._$AA.nextSibling.data=e:this.T(N.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:i}=e,r=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Y.createElement(Dt(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(n);else{let o=new Pe(r,this),s=o.u(this.options);o.p(n),this.T(s),this._$AH=o}}_$AC(e){let n=Ot.get(e.strings);return n===void 0&&Ot.set(e.strings,n=new Y(e)),n}k(e){Xe(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,i,r=0;for(let o of e)r===n.length?n.push(i=new t(this.O(Z()),this.O(Z()),this,this.options)):i=n[r],i._$AI(o),r++;r<n.length&&(this._$AR(i&&i._$AB.nextSibling,r),n.length=r)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let i=It(e).nextSibling;It(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},j=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,i,r,o){this.type=1,this._$AH=y,this._$AN=void 0,this.element=e,this.name=n,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=y}_$AI(e,n=this,i,r){let o=this.strings,s=!1;if(o===void 0)e=P(this,e,n,0),s=!q(e)||e!==this._$AH&&e!==S,s&&(this._$AH=e);else{let a=e,c,l;for(e=o[0],c=0;c<o.length-1;c++)l=P(this,a[i+c],n,c),l===S&&(l=this._$AH[c]),s||=!q(l)||l!==this._$AH[c],l===y?e=y:e!==y&&(e+=(l??"")+o[c+1]),this._$AH[c]=l}s&&!r&&this.j(e)}j(e){e===y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},je=class extends j{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===y?void 0:e}},Ve=class extends j{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==y)}},Ge=class extends j{constructor(e,n,i,r,o){super(e,n,i,r,o),this.type=5}_$AI(e,n=this){if((e=P(this,e,n,0)??y)===S)return;let i=this._$AH,r=e===y&&i!==y||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==y&&(i===y||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},We=class{constructor(e,n,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){P(this,e)}};var Er=Ke.litHtmlPolyfillSupport;Er?.(Y,J),(Ke.litHtmlVersions??=[]).push("3.3.3");var Ft=(t,e,n)=>{let i=n?.renderBefore??e,r=i._$litPart$;if(r===void 0){let o=n?.renderBefore??null;i._$litPart$=r=new J(e.insertBefore(Z(),o),o,void 0,n??{})}return r._$AI(t),r};var qe=globalThis,V=class extends E{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Ft(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return S}};V._$litElement$=!0,V.finalized=!0,qe.litElementHydrateSupport?.({LitElement:V});var Sr=qe.litElementPolyfillSupport;Sr?.({LitElement:V});(qe.litElementVersions??=[]).push("4.2.2");var Ht={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},zt=t=>(...e)=>({_$litDirective$:t,values:e}),me=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,i){this._$Ct=e,this._$AM=n,this._$Ci=i}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var Q=class extends me{constructor(e){if(super(e),this.it=y,e.type!==Ht.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===y||e==null)return this._t=void 0,this.it=e;if(e===S)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Q.directiveName="unsafeHTML",Q.resultType=1;var Ar=zt(Q);var kr=[["manage","Overview"],["manage-bundles","Bundles"],["manage-scans","Scans"],["manage-reports","Reports"],["manage-repos","Repositories","admin"],["admin-users","Users","admin"],["manage-teams","Teams","admin"],["manage-import","Import","admin"],["manage-links","Links"],["manage-history","History"]];function Pt(t,e,n=!1){return v`<header class="manage-header"><nav class="manage-nav" aria-label="Management pages">${kr.filter(([i,,r])=>(r==null||r===e)&&(i!=="manage-links"||n)).map(([i,r])=>v`<button type="button" aria-current="${t===i?"page":y}" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:i},bubbles:!0,composed:!0}))}}">${r}</button>`)}</nav></header>`}var jt=`:host{display:flex;flex-direction:column;position:relative;padding:0 clamp(1rem,3vw,3rem) 3rem;color:var(--text);container-type:inline-size;font-family:var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);font-size:.875rem;line-height:1.5;--panel:color-mix(in srgb, var(--bg) 50%, var(--surface));--panel-hover:color-mix(in srgb, var(--text) 3%, var(--panel))}*,*:before,*:after{box-sizing:border-box}button,summary,select,label,legend,h1,h2,h3,.section-heading,.ui-hint,.page-intro>.intro,.count,.result-count,.repository-count,.breadcrumb-separator,.list-head,.report-list-head,.history-head,.drop-copy,.local-import-copy,.location-field>span,.empty:not(.error,[role=alert]),.msg:not(.error,[role=alert]),.local-import-message:not(.error,[role=status]),.data-empty,.revision-empty{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}.wrap{width:100%;max-width:76rem;margin:0 auto;flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable}.manage-header{position:sticky;top:0;z-index:2}.wrap:has(>.manage-list){display:flex;flex-direction:column;overflow:hidden;scrollbar-gutter:auto}.wrap:has(>.manage-list)>:not(.manage-list){flex-shrink:0}.manage-list{position:relative;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}.manage-nav button{flex:0 0 auto;position:relative;min-height:3.7rem;padding:.9rem 0;border:0;border-radius:0;color:var(--muted);background:none;font-size:.8rem;font-weight:500;white-space:nowrap}.manage-nav button:hover,.manage-nav button[aria-current=page]{color:var(--text)}.manage-nav button[aria-current=page]:after{content:"";position:absolute;bottom:.6rem;inset-inline:0;height:2px;background:var(--accent);border-radius:var(--ui-radius, 2px)}.manage-nav button:focus-visible{outline-offset:-3px}.head{display:flex;align-items:center;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem}h1,.head h1{margin:0;font-size:1.9rem;font-weight:600;letter-spacing:-.045em;line-height:1.2}.count{display:inline-flex;align-items:center;justify-content:center;min-width:1.6rem;padding:.12rem .5rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--surface);font-size:.73rem;font-weight:500;font-variant-numeric:tabular-nums}button,input,select{font:inherit}button,select,input[type=checkbox]{cursor:default}button,a,input,select{-webkit-app-region:no-drag}button,a{transition:background .15s,color .15s,border-color .15s}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}button:disabled,select:disabled{opacity:.45}input:not([type=checkbox]),select{min-width:0;min-height:2.25rem;padding:.45rem .65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--bg);color:var(--text);font-size:.8rem}input::placeholder{color:var(--muted)}input[type=checkbox]{accent-color:var(--accent)}.btn,.drop-browse{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;min-height:2.25rem;height:auto;padding:.45rem .8rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--surface);color:var(--text);font-size:.8rem;font-weight:500;text-decoration:none;white-space:nowrap}.btn:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--surface-active);border-color:var(--muted)}.btn.primary,.drop-browse{color:var(--bg);background:var(--accent);border-color:var(--accent)}.btn.primary:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--accent);filter:brightness(1.08)}.btn svg,.icon-btn svg{width:1rem;height:1rem}.icon-btn{width:2rem;height:2rem}.avatar{color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--bg));border:1px solid color-mix(in srgb,var(--accent) 16%,var(--border))}.breadcrumb{display:flex;align-items:center;flex-basis:100%;gap:.4rem;margin-bottom:.8rem}.breadcrumb-manage{padding:.1rem 0;border:0;background:transparent;color:var(--muted);font-size:.78rem}.breadcrumb-manage:hover{color:var(--text)}.breadcrumb-separator{color:var(--muted)}.msg{margin:1rem 0;padding:1.1rem 1.25rem;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);color:var(--muted);font-size:.85rem}.msg.error{color:var(--critical);border-color:color-mix(in srgb,var(--critical) 35%,var(--border))}.empty{padding:3.5rem 1.5rem;border:1px dashed var(--border);border-radius:var(--ui-radius, 10px);color:var(--muted);text-align:center}.empty strong{display:block;margin-bottom:.4rem;color:var(--text);font-size:.95rem;font-weight:500}.empty p{margin:0;font-size:.85rem}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@container (max-width: 35rem){.drop-copy>span{display:none}.manage-nav{gap:1.2rem;margin-bottom:1.75rem}.manage-nav button{min-height:3.25rem}h1,.head h1{font-size:1.65rem}.intro{margin-bottom:1.5rem}}@media(prefers-reduced-motion:reduce){button,a{transition:none}}.collection-toolbar input{flex:1;max-width:26rem;min-width:10rem}.collection-toolbar select{min-width:10rem}.result-count{text-align:right;white-space:nowrap;margin-left:auto;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}@container (max-width: 35rem){.collection-toolbar input{flex-basis:100%;max-width:none}}.manage-nav{display:flex;gap:1.35rem;align-items:stretch;overflow-x:auto;scrollbar-width:thin;border-bottom:1px solid var(--border);margin-bottom:1.5rem;padding:0 .1rem}.wrap>:not(.manage-header),.manage-nav{-webkit-app-region:no-drag;app-region:no-drag}@media(display-mode:window-controls-overlay){.manage-header{display:flow-root}.manage-header:before{content:"";float:right;width:var(--wco-right-toolbar, 0px);height:var(--wco-titlebar-height)}.manage-nav{width:max-content;max-width:100%;border-bottom:0}.manage-nav button{min-height:var(--wco-titlebar-height);padding-block:.35rem}.manage-nav button[aria-current=page]:after{bottom:0}}.intro{margin:0 0 1.25rem;max-width:46rem;color:var(--muted);font-size:.875rem;line-height:1.65}.collection-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-bottom:.85rem}.page-intro{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.5rem 1rem;margin-bottom:1.25rem}.page-intro .intro{margin:0}a{cursor:default}.loading-rows{border:1px solid var(--border);border-radius:var(--ui-radius, 10px);overflow:hidden}.loading-row{display:grid;align-content:center;gap:.6rem;min-height:4.25rem;padding:.85rem 1rem}.loading-row+.loading-row{border-top:1px solid var(--border)}.loading-row span{width:40%;height:.65rem;border-radius:3px;background:color-mix(in srgb,var(--muted) 15%,transparent)}.loading-row span+span{width:65%;height:.5rem}.drop-card{display:flex;align-items:center;gap:.75rem;margin-bottom:1rem;padding:.7rem .85rem;border:1px dashed color-mix(in srgb,var(--muted) 35%,var(--border));border-radius:var(--ui-radius, 8px);background:var(--panel)}.drop-icon{display:grid;place-items:center;flex-shrink:0;width:1.8rem;height:1.8rem;color:var(--muted)}.drop-icon svg{width:1.1rem;height:1.1rem}.drop-copy{min-width:0;display:flex;align-items:baseline;flex-wrap:wrap;gap:.2rem .6rem}.drop-copy strong{font-size:.8rem;font-weight:500}.drop-copy>span{color:var(--muted);font-size:.75rem}.drop-browse{min-width:7rem;margin-left:auto;flex-shrink:0}
|
|
4
|
-
`;var
|
|
5
|
-
`;var
|
|
6
|
-
`)){let
|
|
7
|
-
`)}var
|
|
8
|
-
`);return e===-1?{title:t.trim(),body:""}:{title:t.slice(0,e).trim(),body:t.slice(e+1)}}function
|
|
9
|
-
`).map(
|
|
10
|
-
`)),r=null,
|
|
11
|
-
`)){let u=/^ {0,3}(```|~~~)/u.exec(p),
|
|
12
|
-
`).trim()}}function
|
|
13
|
-
`?
|
|
14
|
-
### `);
|
|
1
|
+
var _e=globalThis,$e=_e.ShadowRoot&&(_e.ShadyCSS===void 0||_e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Kt=Symbol(),Wt=new WeakMap,xe=class{constructor(e,n,o){if(this._$cssResult$=!0,o!==Kt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}get styleSheet(){let e=this.o,n=this.t;if($e&&e===void 0){let o=n!==void 0&&n.length===1;o&&(e=Wt.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),o&&Wt.set(n,e))}return e}toString(){return this.cssText}},ne=t=>new xe(typeof t=="string"?t:t+"",void 0,Kt);var Xt=(t,e)=>{if($e)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let o=document.createElement("style"),r=_e.litNonce;r!==void 0&&o.setAttribute("nonce",r),o.textContent=n.cssText,t.appendChild(o)}},Je=$e?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let o of e.cssRules)n+=o.cssText;return ne(n)})(t):t;var{is:Hr,defineProperty:jr,getOwnPropertyDescriptor:Vr,getOwnPropertyNames:Gr,getOwnPropertySymbols:Wr,getPrototypeOf:Kr}=Object,Ee=globalThis,Zt=Ee.trustedTypes,Xr=Zt?Zt.emptyScript:"",Zr=Ee.reactiveElementPolyfillSupport,re=(t,e)=>t,Qe={toAttribute(t,e){switch(e){case Boolean:t=t?Xr:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},Yt=(t,e)=>!Hr(t,e),qt={attribute:!0,type:String,converter:Qe,reflect:!1,useDefault:!1,hasChanged:Yt};Symbol.metadata??=Symbol("metadata"),Ee.litPropertyMetadata??=new WeakMap;var I=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=qt){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let o=Symbol(),r=this.getPropertyDescriptor(e,o,n);r!==void 0&&jr(this.prototype,e,r)}}static getPropertyDescriptor(e,n,o){let{get:r,set:i}=Vr(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:r,set(s){let c=r?.call(this);i?.call(this,s),this.requestUpdate(e,c,o)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??qt}static _$Ei(){if(this.hasOwnProperty(re("elementProperties")))return;let e=Kr(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(re("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(re("properties"))){let n=this.properties,o=[...Gr(n),...Wr(n)];for(let r of o)this.createProperty(r,n[r])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[o,r]of n)this.elementProperties.set(o,r)}this._$Eh=new Map;for(let[n,o]of this.elementProperties){let r=this._$Eu(n,o);r!==void 0&&this._$Eh.set(r,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let o=new Set(e.flat(1/0).reverse());for(let r of o)n.unshift(Je(r))}else e!==void 0&&n.push(Je(e));return n}static _$Eu(e,n){let o=n.attribute;return o===!1?void 0:typeof o=="string"?o:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,n=this.constructor.elementProperties;for(let o of n.keys())this.hasOwnProperty(o)&&(e.set(o,this[o]),delete this[o]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Xt(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,n,o){this._$AK(e,o)}_$ET(e,n){let o=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,o);if(r!==void 0&&o.reflect===!0){let i=(o.converter?.toAttribute!==void 0?o.converter:Qe).toAttribute(n,o.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,n){let o=this.constructor,r=o._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let i=o.getPropertyOptions(r),s=typeof i.converter=="function"?{fromAttribute:i.converter}:i.converter?.fromAttribute!==void 0?i.converter:Qe;this._$Em=r;let c=s.fromAttribute(n,i.type);this[r]=c??this._$Ej?.get(r)??c,this._$Em=null}}requestUpdate(e,n,o,r=!1,i){if(e!==void 0){let s=this.constructor;if(r===!1&&(i=this[e]),o??=s.getPropertyOptions(e),!((o.hasChanged??Yt)(i,n)||o.useDefault&&o.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,o))))return;this.C(e,n,o)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,n,{useDefault:o,reflect:r,wrapped:i},s){o&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??n??this[e]),i!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||o||(n=void 0),this._$AL.set(e,n)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,i]of this._$Ep)this[r]=i;this._$Ep=void 0}let o=this.constructor.elementProperties;if(o.size>0)for(let[r,i]of o){let{wrapped:s}=i,c=this[r];s!==!0||this._$AL.has(r)||c===void 0||this.C(r,void 0,i,c)}}let e=!1,n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),this._$EO?.forEach(o=>o.hostUpdate?.()),this.update(n)):this._$EM()}catch(o){throw e=!1,this._$EM(),o}e&&this._$AE(n)}willUpdate(e){}_$AE(e){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(e){}firstUpdated(e){}};I.elementStyles=[],I.shadowRootOptions={mode:"open"},I[re("elementProperties")]=new Map,I[re("finalized")]=new Map,Zr?.({ReactiveElement:I}),(Ee.reactiveElementVersions??=[]).push("2.1.2");var st=globalThis,Jt=t=>t,Ae=st.trustedTypes,Qt=Ae?Ae.createPolicy("lit-html",{createHTML:t=>t}):void 0,sn="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,an="?"+C,qr=`<${an}>`,U=document,ie=()=>U.createComment(""),se=t=>t===null||typeof t!="object"&&typeof t!="function",at=Array.isArray,Yr=t=>at(t)||typeof t?.[Symbol.iterator]=="function",et=`[
|
|
2
|
+
\f\r]`,oe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,en=/-->/g,tn=/>/g,B=RegExp(`>|${et}(?:([^\\s"'>=/]+)(${et}*=${et}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),nn=/'/g,rn=/"/g,cn=/^(?:script|style|textarea|title)$/i,ct=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),x=ct(1),As=ct(2),ks=ct(3),R=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),on=new WeakMap,D=U.createTreeWalker(U,129);function ln(t,e){if(!at(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Qt!==void 0?Qt.createHTML(e):e}var Jr=(t,e)=>{let n=t.length-1,o=[],r,i=e===2?"<svg>":e===3?"<math>":"",s=oe;for(let c=0;c<n;c++){let a=t[c],l,d,p=-1,u=0;for(;u<a.length&&(s.lastIndex=u,d=s.exec(a),d!==null);)u=s.lastIndex,s===oe?d[1]==="!--"?s=en:d[1]!==void 0?s=tn:d[2]!==void 0?(cn.test(d[2])&&(r=RegExp("</"+d[2],"g")),s=B):d[3]!==void 0&&(s=B):s===B?d[0]===">"?(s=r??oe,p=-1):d[1]===void 0?p=-2:(p=s.lastIndex-d[2].length,l=d[1],s=d[3]===void 0?B:d[3]==='"'?rn:nn):s===rn||s===nn?s=B:s===en||s===tn?s=oe:(s=B,r=void 0);let f=s===B&&t[c+1].startsWith("/>")?" ":"";i+=s===oe?a+qr:p>=0?(o.push(l),a.slice(0,p)+sn+a.slice(p)+C+f):a+C+(p===-2?c:f)}return[ln(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),o]},ae=class t{constructor({strings:e,_$litType$:n},o){let r;this.parts=[];let i=0,s=0,c=e.length-1,a=this.parts,[l,d]=Jr(e,n);if(this.el=t.createElement(l,o),D.currentNode=this.el.content,n===2||n===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(r=D.nextNode())!==null&&a.length<c;){if(r.nodeType===1){if(r.hasAttributes())for(let p of r.getAttributeNames())if(p.endsWith(sn)){let u=d[s++],f=r.getAttribute(p).split(C),m=/([.?@])?(.*)/.exec(u);a.push({type:1,index:i,name:m[2],strings:f,ctor:m[1]==="."?nt:m[1]==="?"?rt:m[1]==="@"?ot:X}),r.removeAttribute(p)}else p.startsWith(C)&&(a.push({type:6,index:i}),r.removeAttribute(p));if(cn.test(r.tagName)){let p=r.textContent.split(C),u=p.length-1;if(u>0){r.textContent=Ae?Ae.emptyScript:"";for(let f=0;f<u;f++)r.append(p[f],ie()),D.nextNode(),a.push({type:2,index:++i});r.append(p[u],ie())}}}else if(r.nodeType===8)if(r.data===an)a.push({type:2,index:i});else{let p=-1;for(;(p=r.data.indexOf(C,p+1))!==-1;)a.push({type:7,index:i}),p+=C.length-1}i++}}static createElement(e,n){let o=U.createElement("template");return o.innerHTML=e,o}};function K(t,e,n=t,o){if(e===R)return e;let r=o!==void 0?n._$Co?.[o]:n._$Cl,i=se(e)?void 0:e._$litDirective$;return r?.constructor!==i&&(r?._$AO?.(!1),i===void 0?r=void 0:(r=new i(t),r._$AT(t,n,o)),o!==void 0?(n._$Co??=[])[o]=r:n._$Cl=r),r!==void 0&&(e=K(t,r._$AS(t,e.values),r,o)),e}var tt=class{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:n},parts:o}=this._$AD,r=(e?.creationScope??U).importNode(n,!0);D.currentNode=r;let i=D.nextNode(),s=0,c=0,a=o[0];for(;a!==void 0;){if(s===a.index){let l;a.type===2?l=new ce(i,i.nextSibling,this,e):a.type===1?l=new a.ctor(i,a.name,a.strings,this,e):a.type===6&&(l=new it(i,this,e)),this._$AV.push(l),a=o[++c]}s!==a?.index&&(i=D.nextNode(),s++)}return D.currentNode=U,r}p(e){let n=0;for(let o of this._$AV)o!==void 0&&(o.strings!==void 0?(o._$AI(e,o,n),n+=o.strings.length-2):o._$AI(e[n])),n++}},ce=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,o,r){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=o,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,n=this._$AM;return n!==void 0&&e?.nodeType===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=K(this,e,n),se(e)?e===b||e==null||e===""?(this._$AH!==b&&this._$AR(),this._$AH=b):e!==this._$AH&&e!==R&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Yr(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==b&&se(this._$AH)?this._$AA.nextSibling.data=e:this.T(U.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:o}=e,r=typeof o=="number"?this._$AC(e):(o.el===void 0&&(o.el=ae.createElement(ln(o.h,o.h[0]),this.options)),o);if(this._$AH?._$AD===r)this._$AH.p(n);else{let i=new tt(r,this),s=i.u(this.options);i.p(n),this.T(s),this._$AH=i}}_$AC(e){let n=on.get(e.strings);return n===void 0&&on.set(e.strings,n=new ae(e)),n}k(e){at(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,o,r=0;for(let i of e)r===n.length?n.push(o=new t(this.O(ie()),this.O(ie()),this,this.options)):o=n[r],o._$AI(i),r++;r<n.length&&(this._$AR(o&&o._$AB.nextSibling,r),n.length=r)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let o=Jt(e).nextSibling;Jt(e).remove(),e=o}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},X=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,o,r,i){this.type=1,this._$AH=b,this._$AN=void 0,this.element=e,this.name=n,this._$AM=r,this.options=i,o.length>2||o[0]!==""||o[1]!==""?(this._$AH=Array(o.length-1).fill(new String),this.strings=o):this._$AH=b}_$AI(e,n=this,o,r){let i=this.strings,s=!1;if(i===void 0)e=K(this,e,n,0),s=!se(e)||e!==this._$AH&&e!==R,s&&(this._$AH=e);else{let c=e,a,l;for(e=i[0],a=0;a<i.length-1;a++)l=K(this,c[o+a],n,a),l===R&&(l=this._$AH[a]),s||=!se(l)||l!==this._$AH[a],l===b?e=b:e!==b&&(e+=(l??"")+i[a+1]),this._$AH[a]=l}s&&!r&&this.j(e)}j(e){e===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},nt=class extends X{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===b?void 0:e}},rt=class extends X{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==b)}},ot=class extends X{constructor(e,n,o,r,i){super(e,n,o,r,i),this.type=5}_$AI(e,n=this){if((e=K(this,e,n,0)??b)===R)return;let o=this._$AH,r=e===b&&o!==b||e.capture!==o.capture||e.once!==o.once||e.passive!==o.passive,i=e!==b&&(o===b||r);r&&this.element.removeEventListener(this.name,this,o),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},it=class{constructor(e,n,o){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=o}get _$AU(){return this._$AM._$AU}_$AI(e){K(this,e)}};var Qr=st.litHtmlPolyfillSupport;Qr?.(ae,ce),(st.litHtmlVersions??=[]).push("3.3.3");var dn=(t,e,n)=>{let o=n?.renderBefore??e,r=o._$litPart$;if(r===void 0){let i=n?.renderBefore??null;o._$litPart$=r=new ce(e.insertBefore(ie(),i),i,void 0,n??{})}return r._$AI(t),r};var lt=globalThis,Z=class extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=dn(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return R}};Z._$litElement$=!0,Z.finalized=!0,lt.litElementHydrateSupport?.({LitElement:Z});var eo=lt.litElementPolyfillSupport;eo?.({LitElement:Z});(lt.litElementVersions??=[]).push("4.2.2");var un={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},pn=t=>(...e)=>({_$litDirective$:t,values:e}),ke=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,o){this._$Ct=e,this._$AM=n,this._$Ci=o}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var le=class extends ke{constructor(e){if(super(e),this.it=b,e.type!==un.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===b||e==null)return this._t=void 0,this.it=e;if(e===R)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};le.directiveName="unsafeHTML",le.resultType=1;var to=pn(le);var no=[["manage","Overview"],["manage-bundles","Bundles"],["manage-scans","Scans"],["manage-reports","Reports"],["manage-deduplication","Deduplication","admin"],["manage-repos","Repositories","admin"],["admin-users","Users","admin"],["manage-teams","Teams","admin"],["manage-import","Import","admin"],["manage-links","Links"],["manage-history","History"]];function fn(t,e,n=!1){return x`<header class="manage-header"><nav class="manage-nav" aria-label="Management pages">${no.filter(([o,,r])=>(r==null||r===e)&&(o!=="manage-links"||n)).map(([o,r])=>x`<button type="button" aria-current="${t===o?"page":b}" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:o},bubbles:!0,composed:!0}))}}">${r}</button>`)}</nav></header>`}var mn=`:host{display:flex;flex-direction:column;position:relative;padding:0 clamp(1rem,3vw,3rem) 3rem;color:var(--text);container-type:inline-size;font-family:var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);font-size:.875rem;line-height:1.5;--panel:color-mix(in srgb, var(--bg) 50%, var(--surface));--panel-hover:color-mix(in srgb, var(--text) 3%, var(--panel))}*,*:before,*:after{box-sizing:border-box}button,summary,select,label,legend,h1,h2,h3,.section-heading,.ui-hint,.page-intro>.intro,.count,.result-count,.repository-count,.breadcrumb-separator,.list-head,.report-list-head,.history-head,.drop-copy,.local-import-copy,.location-field>span,.empty:not(.error,[role=alert]),.msg:not(.error,[role=alert]),.local-import-message:not(.error,[role=status]),.data-empty,.revision-empty{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}.wrap{width:100%;max-width:76rem;margin:0 auto;flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable}.manage-header{position:sticky;top:0;z-index:2}.wrap:has(>.manage-list){display:flex;flex-direction:column;overflow:hidden;scrollbar-gutter:auto}.wrap:has(>.manage-list)>:not(.manage-list){flex-shrink:0}.manage-list{position:relative;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}.manage-nav button{flex:0 0 auto;position:relative;min-height:3.7rem;padding:.9rem 0;border:0;border-radius:0;color:var(--muted);background:none;font-size:.8rem;font-weight:500;white-space:nowrap}.manage-nav button:hover,.manage-nav button[aria-current=page]{color:var(--text)}.manage-nav button[aria-current=page]:after{content:"";position:absolute;bottom:.6rem;inset-inline:0;height:2px;background:var(--accent);border-radius:var(--ui-radius, 2px)}.manage-nav button:focus-visible{outline-offset:-3px}.head{display:flex;align-items:center;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem}h1,.head h1{margin:0;font-size:1.9rem;font-weight:600;letter-spacing:-.045em;line-height:1.2}.count{display:inline-flex;align-items:center;justify-content:center;min-width:1.6rem;padding:.12rem .5rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--surface);font-size:.73rem;font-weight:500;font-variant-numeric:tabular-nums}button,input,select{font:inherit}button,select,input[type=checkbox]{cursor:default}button,a,input,select{-webkit-app-region:no-drag}button,a{transition:background .15s,color .15s,border-color .15s}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}button:disabled,select:disabled{opacity:.45}input:not([type=checkbox]),select{min-width:0;min-height:2.25rem;padding:.45rem .65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--bg);color:var(--text);font-size:.8rem}input::placeholder{color:var(--muted)}input[type=checkbox]{accent-color:var(--accent)}.btn,.drop-browse{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;min-height:2.25rem;height:auto;padding:.45rem .8rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--surface);color:var(--text);font-size:.8rem;font-weight:500;text-decoration:none;white-space:nowrap}.btn:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--surface-active);border-color:var(--muted)}.btn.primary,.drop-browse{color:var(--bg);background:var(--accent);border-color:var(--accent)}.btn.primary:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--accent);filter:brightness(1.08)}.btn svg,.icon-btn svg{width:1rem;height:1rem}.icon-btn{width:2rem;height:2rem}.avatar{color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--bg));border:1px solid color-mix(in srgb,var(--accent) 16%,var(--border))}.breadcrumb{display:flex;align-items:center;flex-basis:100%;gap:.4rem;margin-bottom:.8rem}.breadcrumb-manage{padding:.1rem 0;border:0;background:transparent;color:var(--muted);font-size:.78rem}.breadcrumb-manage:hover{color:var(--text)}.breadcrumb-separator{color:var(--muted)}.msg{margin:1rem 0;padding:1.1rem 1.25rem;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);color:var(--muted);font-size:.85rem}.msg.error{color:var(--critical);border-color:color-mix(in srgb,var(--critical) 35%,var(--border))}.empty{padding:3.5rem 1.5rem;border:1px dashed var(--border);border-radius:var(--ui-radius, 10px);color:var(--muted);text-align:center}.empty strong{display:block;margin-bottom:.4rem;color:var(--text);font-size:.95rem;font-weight:500}.empty p{margin:0;font-size:.85rem}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@container (max-width: 35rem){.drop-copy>span{display:none}.manage-nav{gap:1.2rem;margin-bottom:1.75rem}.manage-nav button{min-height:3.25rem}h1,.head h1{font-size:1.65rem}.intro{margin-bottom:1.5rem}}@media(prefers-reduced-motion:reduce){button,a{transition:none}}.collection-toolbar input{flex:1;max-width:26rem;min-width:10rem}.collection-toolbar select{min-width:10rem}.result-count{text-align:right;white-space:nowrap;margin-left:auto;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}@container (max-width: 35rem){.collection-toolbar input{flex-basis:100%;max-width:none}}.manage-nav{display:flex;gap:1.35rem;align-items:stretch;overflow-x:auto;scrollbar-width:thin;border-bottom:1px solid var(--border);margin-bottom:1.5rem;padding:0 .1rem}.wrap>:not(.manage-header),.manage-nav{-webkit-app-region:no-drag;app-region:no-drag}@media(display-mode:window-controls-overlay){.manage-header{display:flow-root}.manage-header:before{content:"";float:right;width:var(--wco-right-toolbar, 0px);height:var(--wco-titlebar-height)}.manage-nav{width:max-content;max-width:100%;border-bottom:0}.manage-nav button{min-height:var(--wco-titlebar-height);padding-block:.35rem}.manage-nav button[aria-current=page]:after{bottom:0}}.intro{margin:0 0 1.25rem;max-width:46rem;color:var(--muted);font-size:.875rem;line-height:1.65}.collection-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-bottom:.85rem}.page-intro{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.5rem 1rem;margin-bottom:1.25rem}.page-intro .intro{margin:0}a{cursor:default}.loading-rows{border:1px solid var(--border);border-radius:var(--ui-radius, 10px);overflow:hidden}.loading-row{display:grid;align-content:center;gap:.6rem;min-height:4.25rem;padding:.85rem 1rem}.loading-row+.loading-row{border-top:1px solid var(--border)}.loading-row span{width:40%;height:.65rem;border-radius:3px;background:color-mix(in srgb,var(--muted) 15%,transparent)}.loading-row span+span{width:65%;height:.5rem}.drop-card{display:flex;align-items:center;gap:.75rem;margin-bottom:1rem;padding:.7rem .85rem;border:1px dashed color-mix(in srgb,var(--muted) 35%,var(--border));border-radius:var(--ui-radius, 8px);background:var(--panel)}.drop-icon{display:grid;place-items:center;flex-shrink:0;width:1.8rem;height:1.8rem;color:var(--muted)}.drop-icon svg{width:1.1rem;height:1.1rem}.drop-copy{min-width:0;display:flex;align-items:baseline;flex-wrap:wrap;gap:.2rem .6rem}.drop-copy strong{font-size:.8rem;font-weight:500}.drop-copy>span{color:var(--muted);font-size:.75rem}.drop-browse{min-width:7rem;margin-left:auto;flex-shrink:0}.content-hidden .filename,.content-hidden .report-name,.content-hidden .report-uploader{color:var(--muted)}.status{display:inline-flex;align-items:center;gap:.3rem;width:fit-content;padding:.1rem .4rem;border:1px solid var(--border);border-radius:5px;color:var(--muted);font-size:.65rem}.status:before{content:"";width:.25rem;height:.25rem;border-radius:50%;background:currentcolor}.status.visible{color:var(--green);border-color:rgb(from var(--green) r g b / .2);background:rgb(from var(--green) r g b / .06)}
|
|
4
|
+
`;var hn=`h1{font-size:1.35rem;margin-bottom:.5rem}h2{font-size:1.1rem;margin-bottom:.5rem}.triage-import{display:flex;gap:1rem;align-items:center;margin:1.5rem 0 2rem}.triage-import .btn{flex-shrink:0}.triage-import p{margin:0}.workspace-drop{display:grid;gap:.8rem;padding:2rem;margin:1.5rem 0;border:1px dashed var(--border);border-radius:var(--ui-radius, 8px)}.workspace-drop.dragging{border-color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.workspace-drop span,p,li span{color:var(--muted);line-height:1.5}.actions,.local-choice{display:flex;gap:.8rem;flex-wrap:wrap;align-items:center}.local-choice{margin-bottom:1.5rem}.import-preview{display:grid;gap:.8rem}input:not([type=radio]),select{padding:.55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);color:var(--text);background:var(--bg);font:inherit}.import-preview input:not([type=radio]),.import-preview select{width:100%;box-sizing:border-box}fieldset{display:grid;gap:.8rem;padding:1rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px)}fieldset label{display:flex;gap:.5rem;align-items:center}li{padding:.4rem 0;overflow-wrap:anywhere}li span{display:block;font-size:.8rem}ul{padding-left:1.2rem}.primary{justify-self:start;color:var(--accent)}.error{color:var(--critical)}button:disabled{opacity:.5}input:focus-visible,select:focus-visible,button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
5
|
+
`;var io=new TextEncoder;function gn(t){if(typeof t!="string")throw new TypeError(`encodeUtf8 expects a string, got ${typeof t}`);if(!t.isWellFormed())throw new TypeError("encodeUtf8: input contains lone surrogates");return io.encode(t)}async function so(t){let e=gn(JSON.stringify(t)),n=await crypto.subtle.digest("SHA-256",e),o=new Uint8Array(n,0,16);o[6]=o[6]&15|64,o[8]=o[8]&63|128;let r=Array.from(o,i=>i.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20,32)}`}async function yn(t){if(typeof crypto?.subtle?.digest!="function")return null;let e=de(t);try{return await so(e)}catch{return null}}function de(t){if(t._idBasis)return t._idBasis;let{severity:e,description:n}=t;return t.fileHash?{severity:e,description:n,fileHash:t.fileHash}:t.location?{severity:e,description:n,location:t.location}:{severity:e,description:n,file:t.file,line:t.line}}var wn=/^( *)(`{3,}|~{3,})(.*)$/u,ao=/^ {0,3}(?:#{1,6}(?:[ \t]|$)|>|([-*_])(?:[ \t]*\1){2,}[ \t]*$)/u,bn=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u,co=/^ {0,3}(?:=+|-+)[ \t]*$/u,F=/^( *)(?:[-*+]|\d{1,9}[.)]) +(?=\S)/u,lo=/^ *(?:[-*+]|\d{1,9}[.)])[ \t]*$/u,vn=/^\s*$/u,uo=[[/^<(script|pre|textarea|style)(?:\s|>|$)/iu,/<\/(?:script|pre|textarea|style)>/iu,t=>`</${t[1].toLowerCase()}>`],[/^<!--/u,/-->/u,"-->"],[/^<\?/u,/\?>/u,"?>"],[/^<![A-Za-z]/u,/>/u,"<!-- -->"],[/^<!\[CDATA\[/u,/\]\]>/u,"]]>"],[/^<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|search|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/iu,vn,null]],po=/^(?:<[A-Za-z][\dA-Za-z-]*(?:\s+[:A-Z_a-z][\w.:-]*(?:\s*=\s*(?:[^\s"'<=>`]+|'[^']*'|"[^"]*"))?)*\s*\/?>|<\/[A-Za-z][\dA-Za-z-]*\s*>)\s*$/u;function Se(t,e,n=e){let o=/^ */u.exec(t)[0].length;if(o>3)return null;if(e&&n&&co.test(t))return!0;let r=wn.exec(t);if(r&&!(r[2][0]==="`"&&r[3].includes("`")))return{fence:r[2]};let i=t.slice(o);for(let[a,l,d]of uo){let p=a.exec(i);if(p)return{html:l,close:typeof d=="function"?d(p):d}}if(!e&&po.test(i))return{html:vn,close:null};let s=bn.test(t)?null:F.exec(t);if(s&&!(e&&n&&/^ *(?:\d*[02-9]|\d+\d)[.)]/u.test(s[0]))){let a=/ +$/u.exec(s[0])[0].length;return{item:a>4?s[0].length-a+1:s[0].length}}let c=bn.test(t)||e&&n?null:lo.exec(t);return c?{item:c[0].trimEnd().length+1}:ao.test(t)||null}function P(t){return dt(t).ranges}function fo(t,e){let n=t.replace(/^(?: {0,3}> ?)+/u,""),o=Se(n,e);for(;o?.item;)n=n.slice(o.item),o=Se(n,!1);return n.trim()!==""&&!o&&/^ */u.exec(n)[0].length<4}function dt(t){let e=[],n=-1,o="",r=null,i=0,s=[],c=!1,a=!1,l=!1,d=0;for(let u of t.split(`
|
|
6
|
+
`)){let f=d;d+=u.length+1;let m=/^ */u.exec(u)[0].length;if(n!==-1||r){let A=i>0&&u.trim()!==""&&m<i,$=!A&&(r?r.ends.test(u):m<=i+3&&_n(o,u));if((A||$)&&(n!==-1&&e.push([n,A?f-1:f+u.length]),n=-1,r=null),!A)continue}if(!u.trim()){l&&s.pop(),l=!1,c=!1;continue}let h=s.length;for(;h>0&&m<s[h-1];)h--;let g=h>0?s[h-1]:0,y=u.slice(g),v=Se(y,c,h===s.length&&!a);if(c&&!v)continue;for(s.length=h;v?.item;)g+=v.item,y=y.slice(v.item),s.push(g),v=Se(y,!1);l=y.trim()==="",v?.fence?[n,o,i]=[f,v.fence,g]:v?.html&&([r,i]=[v.html.test(y)?null:{ends:v.html,close:v.close},g]);let w=c&&a;a=/^ {0,3}>/u.test(y),c=a?fo(y,w):!v&&!l&&/^ */u.exec(y)[0].length<4}n!==-1&&e.push([n,t.length]);let p=n===-1?r?.close:o;return{ranges:e,closer:p?" ".repeat(i)+p:null}}function _n(t,e){let n=wn.exec(e);return n!==null&&n[2][0]===t[0]&&n[2].length>=t.length&&!n[3].trim()}function z(t,e){let n=0,o=t.length;for(;n<o;){let r=n+o>>>1;t[r][1]<=e?n=r+1:o=r}return n<t.length&&e>=t[n][0]}function S(t){return String(t??"").replaceAll(/\r\n?/gu,`
|
|
7
|
+
`)}var Ie=/^## +(.*)$/gmu,ue=/^### +(.*)$/gmu,T=/^#### +(.*)$/gmu,xn=/^##### +(.*)$/gmu,ut=/^(.+):(\d+(?:-\d+)?)$/u;function q(t){return/^[0-9a-f]{7,64}$/iu.test(t)}function $n(t,e){let n=P(t);return[...t.matchAll(e)].filter(o=>!z(n,o.index))}function Re(t,e){let n=$n(t,e);return[t.slice(0,n[0]?.index),...n.map((o,r)=>t.slice(o.index+o[0].length,n[r+1]?.index))]}function L(t,e){let n=$n(t,e);return{head:t.slice(0,n[0]?.index),subs:n.map((o,r)=>({heading:o[1],body:t.slice(o.index+o[0].length+1,n[r+1]?.index)}))}}function M(t,e){return L(t,e).subs}function pe(t){let e=t.indexOf(`
|
|
8
|
+
`);return e===-1?{title:t.trim(),body:""}:{title:t.slice(0,e).trim(),body:t.slice(e+1)}}function fe(t){let e=t.split(`
|
|
9
|
+
`).map(o=>o.trim()).filter(o=>o.startsWith("|")&&!(/^[\s:|-]+$/u.test(o)&&o.includes("-"))).map(o=>o.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(r=>r.trim()));if(e.length<2)return[];let n=e[0].map(o=>o.toLowerCase());return e.slice(1).filter(o=>o.length!==n.length||o.some((r,i)=>r.toLowerCase()!==n[i])).map(o=>Object.fromEntries(n.flatMap((r,i)=>r?[[r,o[i]??""]]:[])))}function En(t){let e=Object.create(null),n=Object.create(null),o=[],r=null,i="",s=[],c="",a=(p,u,f)=>{!p||p in e||(e[p]=f.trim(),n[p]=u)},l=()=>{r&&a(r,i,s.join(`
|
|
10
|
+
`)),r=null,i="",s=[]},d=p=>{(r?s:o).push(p)};for(let p of t.split(`
|
|
11
|
+
`)){let u=/^ {0,3}(```|~~~)/u.exec(p),f=u!==null&&(!c||u[1]===c);if(f&&(c=c?"":u[1]),f||c){d(p);continue}if(!p.trim()){r?l():o.push(p);continue}let m=/^\s*(?:[-*] +)?\*\*([^:*]+):\*\*\s*(.*)$/u.exec(p);if(m){l();let h=m[1].trim(),g=m[2],y;for(;(y=/\s+[·•]\s+\*\*([^:*]+):\*\*\s*/u.exec(g))!==null;)a(h.toLowerCase(),h,g.slice(0,y.index)),h=y[1].trim(),g=g.slice(y.index+y[0].length);r=h.toLowerCase(),i=h,s=[g];continue}if(/^\s*(?:#{1,6} |\||[-=*_]{3,}\s*$)/u.test(p)){l();continue}d(p)}return l(),{fields:e,labels:n,prose:o.join(`
|
|
12
|
+
`).trim()}}function An(t){let e=(t||"").trim(),n="",o=Y(e);o&&(e=o.label.trim(),n=o.url.trim());let r=/#L(\d+)/u.exec(n)?.[1]??"",c=[...e.matchAll(/`([^`]+)`/gu)].map(d=>d[1].trim()).find(d=>!d.includes("(")&&(d.includes("/")||/\.\w/u.test(d)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),a=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(c);a&&(c=a[1],r||(r=a[2]));let l=ut.exec(c);return l?(r||(r=l[2]),{file:l[1],line:r,locationLink:n}):{file:c,line:r||"?",locationLink:n}}function pt(t){return t.replaceAll("**","")}function Y(t){let e=String(t??""),n=mo(e,ho(e)),o=go(e),r=e.indexOf("]");for(let i=e.indexOf("[");i!==-1;i=e.indexOf("[",i+1)){for(;r!==-1&&r<=i;)r=e.indexOf("]",r+1);for(let s of[r,n.get(i)??-1]){if(s===-1||s===i+1||e[s+1]!=="(")continue;let c=yo(e,s+1,o);if(c!==null)return{label:e.slice(i+1,s),url:c,index:i}}}return null}function mo(t,e){let n=new Map,o=[];for(let r=0;r<t.length;r++){let i=t[r];kn(t,r)?r++:i==="`"?r=e.get(r)??r:i==="["?o.push(r):i==="]"&&o.length>0&&n.set(o.pop(),r)}return n}function ho(t){let e=[];for(let r=t.indexOf("`");r!==-1;r=t.indexOf("`",r)){let i=1;for(;t[r+i]==="`";)i++;e.push([r,i]),r+=i}let n=new Map,o=new Map;for(let r=e.length-1;r>=0;r--){let[i,s]=e[r],c=o.get(s);c!==void 0&&n.set(i,c+s-1),o.set(s,i)}return n}function go(t){let e=t.length,n=new Int32Array(e+1).fill(-1),o=new Int32Array(e+1).fill(-1),r=new Int32Array(e+1).fill(-1),i=new Int32Array(e+1).fill(-1);for(let a=e-1;a>=0;a--)n[a]=t[a]===")"?a:n[a+1],o[a]=/\s/u.test(t[a])?a:o[a+1],r[a]=t[a]===">"?a:r[a+1],i[a]=t[a]===`
|
|
13
|
+
`?a:i[a+1];let s=new Map,c=[];for(let a=0;a<e;a++){let l=t[a];kn(t,a)?a++:o[a]===a?c.length=0:l==="("?c.push(a):l===")"&&c.length>0&&s.set(c.pop(),a)}return{balanced:s,nextClose:n,nextSpace:o,nextAngle:r,nextLine:i}}function yo(t,e,n){let o=bo(t,e,n);if(o)return o;let r=n.balanced.get(e);if(r!==void 0)return r>e+1?t.slice(e+1,r):null;let i=n.nextClose[e+1],s=n.nextSpace[e+1];return i===-1||i===e+1||s!==-1&&s<i?null:t.slice(e+1,i)}function bo(t,e,n){if(t[e+1]!=="<")return"";let o=n.nextAngle[e+2],r=n.nextLine[e+2];return o===-1||r!==-1&&r<o||t[o+1]!==")"?"":t.slice(e+2,o)}var wo=/\\([!-/:-@[-`{-~])/gu,vo=/[!-/:-@[-`{-~]/u;function kn(t,e){return t[e]==="\\"&&vo.test(t[e+1]??"")}function Sn(t){return typeof t=="string"?t.replace(wo,"$1"):t}function In(t){let e=/^\[(.+)\]$/u.exec(t.trim());return e?e[1].trim():t.trim()}function H(t){let e=(t||"").trim();return/^[-–—]+$/u.test(e)?"":e}var Ce=new Map([["CRITICAL","critical"],["HIGH","high"],["MEDIUM","medium"],["LOW","low"],["INFO","informational"],["INFORMATIONAL","informational"],["INFORMATIVE","informative"]]);function Rn(t){return typeof t=="string"&&t.trim().toLowerCase()==="informative"?"informational":t}function E(t,e=t.severity){let n=Rn(t.severity);return n!==t.severity&&(!t.id&&!t._idBasis&&(t._idBasis=de({...t,severity:e})),t.severity=n),t.correctedSeverity!==void 0&&(t.correctedSeverity=Rn(t.correctedSeverity)),t}var _o=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu,xo=new Map([...Ce,["HIGH_BUG","high_bug"],["BUG","bug"]]),Ln=t=>String(t??"").toLowerCase().replaceAll(/[^a-z]+/gu,""),Cn=new Map([["high",8],["medium",6],["low",4]]);function $o(t){if(t!==void 0)return Cn.get(Ln(t))??Cn.get("medium")}var Eo=new Map([["confirmed","confirmed"],["falsepositive","refuted"],["uncertain","unknown"]]);function Mn(t){let n=S(t).trim().split(_o);if(n.length===1)return null;let o=[];for(let r=1;r<n.length;r+=2){let i=xo.get(n[r].toUpperCase())??"medium";for(let s of Re(n[r+1],/^### /gmu).slice(1)){let c=Tn(s,i);if(!c)continue;let a=s.indexOf(`
|
|
14
|
+
### `);a!==-1&&(c._idBasis=de(Tn(s.slice(0,a+1),i))),o.push(c)}}return o.length===0?null:{type:"security",source:"deepsec",findings:o}}function Tn(t,e){let{title:n,body:o}=pe(t);if(!n)return null;let r=o.replace(/\n---\s*$/u,"").trim(),i=Object.fromEntries([...r.matchAll(/^- \*\*([^:*]+):\*\*\s*(.+)$/gmu)].map(g=>[g[1].trim().toLowerCase(),g[2].trim()])),s=/^\*\*Recommendation:\*\*\s*/mu.exec(r),c=s?r.slice(0,s.index):r,a=s?r.slice(s.index+s[0].length).trim():"",l=c.split(`
|
|
15
15
|
`).filter(g=>!/^\s*- \*\*/u.test(g)).join(`
|
|
16
16
|
`).replaceAll("**","").trim(),d=[n,l].filter(Boolean).join(`
|
|
17
17
|
|
|
18
|
-
`),p=(
|
|
19
|
-
`).find(e=>e.trim())?.trim()??"":""}function
|
|
20
|
-
`).map(r=>{let o
|
|
21
|
-
`)}function
|
|
22
|
-
`),n=0,
|
|
23
|
-
`)};let s=[];for(;n<e.length&&e[n].trim();)s.push(e[n++]);return
|
|
24
|
-
`).trim()),facts:
|
|
25
|
-
`)}}var
|
|
26
|
-
`)){let
|
|
27
|
-
`).trim());return
|
|
18
|
+
`),p=(i.file||"unknown").replace(/^`(.*)`$/u,"$1"),u=(i.lines||"").split(",").map(g=>g.trim()).find(Boolean)||"?",f={file:p,line:u,severity:e,description:d};a&&(f.recommendation=a.replaceAll("**",""));let m=$o(i.confidence);m!==void 0&&(f.confidence=m);let h=Eo.get(Ln(i.revalidation));return h&&(f.revalidate=h,f.revalidateSource="deepsec",i.reasoning&&(f.revalidateVerdict=i.reasoning.replaceAll("**",""))),i.slug&&(f.slug=i.slug),E(f,e==="informative"?"medium":e)}var On={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High bug",bug:"Bug",informational:"Informational"};var Te={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec",piolium:"Piolium","markdown-generic":"Markdown (generic)"};var ft=["critical","high","medium","low","high_bug","bug","informational"];var Le=["revalidation","refuted","unreachable","confirmed","partial","unknown"],Ao=new Set(Le);function Nn(t){return Ao.has(t?.revalidate)?t.revalidate:""}function mt(t,e=t?.source){return Object.hasOwn(Te,e)||Nn(t)==="revalidation"}function ht(t){return t?t.split(`
|
|
19
|
+
`).find(e=>e.trim())?.trim()??"":""}function gt(t){return Number.isFinite(parseInt(t?.line,10))?`${t.file}:${t.line}`:t?.file??""}function yt(t){if(typeof t!="string"||t.length===0)return!1;try{let e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function ko(t,e){let n=P(t),o=0;return t.split(`
|
|
20
|
+
`).map(r=>{let i=o;return o+=r.length+1,z(n,i)?r:e(r)}).join(`
|
|
21
|
+
`)}function j(t){return ko(String(t??""),e=>e.replace(/^( {0,3})\\(\\*#)/u,"$1$2"))}var So=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/iu,Io=/^[\w.-]+\/[\w.-]+$/u;function bt(t){return Io.test(t)}function me(t){let e=t?.repo?.github;if(typeof e!="string")return null;let n=e.trim().replace(/\/+$/u,"");if(!n)return null;let o=So.exec(n),r=(o?`${o[1]}/${o[2]}`:n).replace(/\.git$/u,"");return bt(r)?r:null}var Bn=[["Impact","impact",!1],["Reproduction","reproduction",!1],["Recommendation","recommendation",!1],["Confidence reasoning","confidenceReason",!1],["Revalidation verdict","revalidateVerdict",!0],["Revalidation recommendation","revalidateRecommendation",!0]],Dn=[["Status","status"],["Branch","branch"],["Date created","dateCreated"],["Detected at","detectedAt"],["Committed at","committedAt"],["PoC status","pocStatus"],["Variant of","parent"],["Slug","slug"],["Priority","priority"]],Un=[["Detailed report","reportPath"],["Commit audited","auditedCommit"],["ID","id"]];var Ro=new Map(Object.entries(On).map(([t,e])=>[e.toLowerCase(),t])),Pn=new Map(Object.entries(Te).map(([t,e])=>[e.toLowerCase(),t]));function V(t){let e=/(`+)(.+?)\1(?!`)/u.exec(String(t??""));if(!e)return null;let n=e[2];if(n.length>2&&n.startsWith(" ")&&n.endsWith(" ")){let o=n.slice(1,-1);if(o.startsWith("`")||o.endsWith("`"))return o}return n}function Oe(t){let e=Y(String(t??""));return e?.index===0?{label:e.label,url:e.url}:null}function zn(t){let e=/^<(https?:[^>\s]*)>$/u.exec(t.trim());return e?e[1]:null}function Hn(t){let e=ut.exec(t);return e?{file:e[1],line:e[2]}:{file:t,line:"?"}}function Co(t){let e=t.indexOf(".");return e>0?{exportName:t.slice(0,e),methodName:t.slice(e+1)}:{exportName:t}}function Me(t){let e=String(t??"").trim();return Ro.get(e.toLowerCase())??e}function To(t){let e={},n=t.trim(),o=/ · (`+)(.+?)\1$/u.exec(n);o&&(Object.assign(e,Co(V(o[0]))),n=n.slice(0,o.index));let r=Oe(n),i=V(r?r.label:n);return i!==null&&Object.assign(e,Hn(i)),r&&yt(r.url)&&(e.location=r.url),e}var Fn=" \xB7 flagged critical by the analyzer",Lo=" (varies across reports \u2014 ";function Mo(t){let e={},n=t.trim();n.endsWith(Fn)&&(e.critical=!0,n=n.slice(0,-Fn.length));let o=n.indexOf(Lo);o!==-1&&(n=n.slice(0,o));let r=/^(.*?) — corrected (from|to) (.*)$/u.exec(n);return r?[e.severity,e.correctedSeverity]=(r[2]==="from"?[r[3],r[1]]:[r[1],r[3]]).map(Me):e.severity=Me(n),e}var Oo=new Set(["max","xhigh","high","medium","low","minimal"]),No=new Set(["list","isolate"]);function Bo(t){return/\d/u.test(t)||/^(?:opus|sonnet|haiku|gpt|gemini|fable|mythos|llama|mistral)\b/iu.test(t)}function Ne(t){let e=t.trim(),n=Pn.get(e.toLowerCase());if(n)return{source:n};let o={},r=[];for(let i of e.split(" \xB7 ").map(s=>s.trim()).filter(Boolean))i==="revalidate"&&!o.revalidate?o.revalidate="revalidation":No.has(i)&&!o.exportsMode?o.exportsMode=i:Oo.has(i)&&!o.effort?o.effort=i:r.push(i);return r.length>1?[o.type,o.model]=r:r.length===1&&(o[Bo(r[0])?"model":"type"]=r[0]),{run:o}}function wt(t){let e=t.trim(),n=Oe(e);return n?n.label.trim():zn(e)??e}function Do(t){let e=Oe(t.trim());if(e){let n=e.url.split("/").at(-1)??"";return q(n)?n:V(e.label)??n}return V(t)??t.trim()}function Uo(t){let e=V(t)??t.trim(),n=e.lastIndexOf("@");return{npm:n>0?{name:e.slice(0,n),version:e.slice(n+1)}:{name:e}}}function Fo(t){let e=t.trim().toLowerCase();return e==="the revalidation pass itself"?"revalidation":Le.includes(e)?e:void 0}var Po=new Map([...[["Category","category"],...Dn].map(([t,e])=>[t.toLowerCase(),(n,o)=>{n[e]=o}]),...[...Un,["Found while analyzing","discoveredIn"]].map(([t,e])=>[t.toLowerCase(),(n,o)=>{n[e]=V(o)??o}]),["location",(t,e)=>Object.assign(t,To(e))],["severity",(t,e)=>Object.assign(t,Mo(e))],["confidence",(t,e)=>{let n=/^(\d+(?:\.\d+)?)\/10$/u.exec(e);n&&(t.confidence=Number(n[1]))}],["revalidation",(t,e)=>{let n=Fo(e);n&&(t.revalidate=n)}],["revalidated by",(t,e)=>{let n=e.trim();n&&(t.revalidateSource=Pn.get(n.toLowerCase())??n)}],["repository",(t,e)=>{t.repo={github:wt(e)}}],["introduced in",(t,e)=>{t.commitHash=Do(e)}],["package",(t,e)=>{t.package=Uo(e)}],["priority",(t,e)=>{t.priority=/^-?\d+(?:\.\d+)?$/u.test(e)?Number(e):e}]]);function jn(t,e,n){let o=Po.get(e.trim().toLowerCase());o&&o(t,n.trim())}var zo=/^- \*\*([^*\n]+?):\*\* ?(.*)$/u;function Vn(t){let e=t.split(`
|
|
22
|
+
`),n=0,o=()=>{for(;n<e.length&&!e[n].trim();)n++},r=()=>{let c=[];for(let a;(a=zo.exec(e[n]??""))!==null;n++)c.push([a[1].trim(),a[2].trim()]);return c};o();let i=r();if(i.length>0)return{title:"",facts:i,rest:e.slice(n).join(`
|
|
23
|
+
`)};let s=[];for(;n<e.length&&e[n].trim();)s.push(e[n++]);return o(),i=r(),i.length===0?{title:"",facts:i,rest:t}:{title:j(s.join(`
|
|
24
|
+
`).trim()),facts:i,rest:e.slice(n).join(`
|
|
25
|
+
`)}}var Ho=/^(\d+)\. (.*)$/u;function Gn(t){let e=[],n=P(t),o=0;for(let r of t.split(`
|
|
26
|
+
`)){let i=z(n,o)?null:Ho.exec(r);o+=r.length+1,i?e.push({ref:i[2].trim(),indent:i[1].length+2,note:[]}):e.length>0&&e.at(-1).note.push(r)}return e.map(r=>jo(r))}function jo({ref:t,indent:e,note:n}){let o={},r=Oe(t),i=zn(t),s=i===null?V(r?r.label:t):null;s!==null&&Object.assign(o,Hn(s));let c=r?r.url:i;yt(c)&&(o.url=c);let a=j(n.map(l=>l.slice(Math.min(e,/^ */u.exec(l)[0].length))).join(`
|
|
27
|
+
`).trim());return a&&(o.text=a),o}var Wn=new Map(Bn.map(([t,e])=>[t.toLowerCase(),e])),Vo=[...Wn.keys()];function Kn(t){let e=t.length,n=1/0;for(let o=t.length-1;o>=0;o--){let r=Vo.indexOf(t[o].label.toLowerCase());if(r===-1||r>=n)break;n=r,e=o}return{paragraphs:t.slice(0,e),fields:t.slice(e).map(o=>[Wn.get(o.label.toLowerCase()),o.body])}}function Xn(t,e,n){let o=[],r=ht(e),i=t.endsWith("\u2026")?t.slice(0,-1).trimEnd():"";!t||r===t||i&&r.startsWith(i)?o.push(e):o.push(t,e);for(let{label:s,body:c}of n)o.push(c?`**${s}:** ${c}`:`**${s}:**`);return o.filter(Boolean).join(`
|
|
28
28
|
|
|
29
|
-
`)}var
|
|
30
|
-
`)
|
|
31
|
-
`),s=(
|
|
29
|
+
`)}var Go=/^<!--\s*DeepView findings export\b[^>]*-->/u,Wo=/^Case \d+ of \d+(?:\s|$)/u,Ko=/^- \*\*([^*\n]+?):\*\* ?(.*)$/gmu,Xo=new Set(["evidence","severity correction","comment"]);function qn(t){let e=S(t).trim();if(!Go.test(e))return null;let{head:n,subs:o}=L(e,Ie),r=[];for(let{heading:i,body:s}of o){if(i.trim().toLowerCase()==="summary")continue;let c=Zo(i);for(let a of M(s,ue))r.push(Yo(a,c))}return Qo(qo(n),r)}function Zo(t){let e=/^(.*?)\s*\(\d+\)\s*$/u.exec(t.trim());return Me(e?e[1]:t)}function qo(t){let e=new Map;for(let n of t.matchAll(Ko)){let o=n[1].trim().toLowerCase();e.has(o)||e.set(o,n[2].trim())}return{sources:(e.get("source")??"").split(",").map(n=>Ne(n).source).filter(Boolean),analyzers:(e.get("analyzer")??e.get("analyzers")??"").split(";").map(n=>n.trim()).filter(Boolean),repo:e.has("repository")?wt(e.get("repository")):""}}function Yo({heading:t,body:e},n){let o=t.trim().replace(/^\d+\.\s+/u,""),r=M(e,T).filter(i=>Wo.test(i.heading.trim()));return r.length===0?[Zn(e,T,o,n)]:r.map(i=>Zn(i.body,xn,o,n))}function Zn(t,e,n,o){let{title:r,facts:i,rest:s}=Vn(t),{head:c,subs:a}=L(s,e),l=a.map(w=>({label:w.heading.trim(),body:w.body.trim()})),d={file:"unknown",line:"?"},p=null;for(let[w,A]of i)w.trim().toLowerCase()==="analyzer"?p=Ne(A):jn(d,w,A);d.severity||(d.severity=o||"medium");let u=r||n,f=u!=="Untitled finding"&&u!==gt(d),m=l.filter(w=>!Xo.has(w.label.toLowerCase())).map(w=>({label:w.label,body:j(w.body)})),{paragraphs:h,fields:g}=Kn(m);d.description=Xn(f?u:"",j(c.trim()),h);let y=l.filter(w=>w.label.toLowerCase()==="evidence").flatMap(w=>Gn(w.body));y.length>0&&(d.evidence=y);for(let[w,A]of g)d[w]=A;let v=l.find(w=>w.label.toLowerCase()==="severity correction");return v?.body&&(d.correctedSeverityReason=j(v.body)),{finding:E(d),analyzer:p}}function Jo(t,e){let n={source:null,run:{}};if(e.some(r=>r.analyzer!==null)){let r=new Set(e.map(i=>i.analyzer?.source??null));r.size===1&&!r.has(null)&&([n.source]=r);for(let i of e)i.analyzer?.run?Object.assign(i.finding,i.analyzer.run):i.analyzer?.source&&!n.source&&(i.finding.source=i.analyzer.source);return n}let o=t.analyzers.length===1?Ne(t.analyzers[0]):null;return o?.source?n.source=o.source:o?.run?n.run=o.run:t.analyzers.length===0&&t.sources.length===1&&([n.source]=t.sources),n}function Qo(t,e){let n=e.flat(),{source:o,run:r}=Jo(t,n),i={},s=new Set(n.map(l=>l.finding.type).filter(Boolean)),c=r.type??(s.size===1?[...s][0]:null)??(o?"security":null);c&&(i.type=c),o&&(i.source=o);for(let l of["model","effort","exportsMode"])r[l]&&(i[l]=r[l]);t.repo&&(i.repo={github:t.repo});let a=e.map(l=>l.map(d=>d.finding));return a.every(l=>l.length===1)?i.findings=a.flat():i.groups=a,i}var vt="markdown-generic",ei=["#","id","product","priority","vulnerability"],ti=["title","description","root cause","code references","attack scenario","steps to reproduce","impact","patch"],ni=/^(?:#{3,6}[ \t]+)?(?:\*\*)?(Title|Description|Root Cause|Code references|Attack Scenario|Steps to Reproduce(?:[ \t]+.*?)?|Impact|Patch):?(?:\*\*)?(?:[ \t]+#+)?[ \t]*$/gimu,Yn={P0:"critical",P1:"high",P2:"medium",P3:"low",P4:"informational"},J=t=>t.trim().slice(1,-1).split("|").map(e=>e.trim());function _(t,e){if(!t)throw new Error(`Markdown (generic): unsupported ${e}`)}function ri(t){return[...new Set(t.split(`
|
|
30
|
+
`).map(e=>e.trim()).filter(Boolean))].map(e=>{_(/^https?:\/\/[^\s()[\]{}"'<>`\\]+$/iu.test(e)&&!/[.,;!?]$/u.test(e),"link syntax; use bare URLs on separate lines");let n;try{n=new URL(e)}catch{_(!1,"URL")}let[o,r,i,s,...c]=n.pathname.slice(1).split("/");_(["github.com","www.github.com"].includes(n.hostname)&&!n.username&&!n.password&&!n.port&&[o,r].every(p=>p&&/^[\w-][\w.-]*$/u.test(p)),"repository URL"),_(c.every(Boolean),"repository path; empty components");let a=`${o}/${r.replace(/\.git$/iu,"")}`.toLowerCase(),l=/^#L(\d+)(?:-L?(\d+))?$/u.exec(n.hash),d=i==="blob"?c.slice(0,-1):i==="tree"?c:[];try{d=d.map(decodeURIComponent)}catch{_(!1,"repository directory encoding")}return _(d.every(p=>p===p.trim()&&!/[\\/:?#\p{Cc}]/u.test(p)),"repository directory"),{repo:a,ref:s,directory:d,...i==="blob"&&c.length&&{evidence:{file:c.join("/"),line:l?l.slice(1).filter(Boolean).join("-"):"?",url:e}}}})}function oi(t,e,n,o){let r=ri(n),i=r[0]?.repo;_(i&&r.every(a=>a.repo===i),`repository set for finding ${t.id}; expected exactly one repository`),_(!t.group.github||t.group.github===i,`repository set for product ${t.product}; expected exactly one repository`);let s=o.get(i);_(s===void 0||s===t.prefix,`repository ID prefixes for ${i}; expected ${s}, got ${t.prefix} (${t.id})`),o.set(i,t.prefix),t.group.github=i,t.group.directories.push(...r.map(a=>a.directory));let c=r.flatMap(a=>a.evidence??[]);if(c.length){Object.assign(e,{file:c[0].file,line:c[0].line,location:c[0].url,evidence:c});let a=r.find(l=>l.evidence).ref;q(a)&&(e.commitHash=a)}}function ii(t){let e=t[0];for(let n of t.slice(1)){let o=0;for(;o<e.length&&e[o]===n[o];)o++;e=e.slice(0,o)}return e.join("/")}function si(t){let e=S(t).trim(),n=[...e.matchAll(/^## +(.*)$/gmu)];if(!n.some(d=>/^\d+\.\s+\S+/u.test(d[1]))&&(n.length||e.startsWith("# ")))return null;let o=[...e.matchAll(/^\|[^\n]*\|$/gmu)].find(([d])=>J(d).map(p=>p.toLowerCase()).join()===ei.join());if(!o)return null;let r=e.slice(0,o.index).trim();_(!r||/^# [^\n]+$/u.test(r),"summary preamble"),_(o.index<(n[0]?.index??e.length),"summary position");let i=e.slice(o.index,n[0]?.index).trim().split(`
|
|
31
|
+
`),s=new Set(J(i[0]).map(d=>d.toLowerCase()));_(i[1]&&J(i[1]).length===5&&J(i[1]).every(d=>/^:?-{3,}:?$/u.test(d)),"summary separator");let c=new Map,a=new Map,l=new Map;for(let d of i.slice(2).filter(p=>p.trim())){_(/^\|.*\|$/u.test(d)&&J(d).length===5,"summary row");let[p,u,f,m]=J(d),h=/^(.+-)\d+$/u.exec(u)?.[1];_(/^\d+$/u.test(p)&&h&&f&&Object.hasOwn(Yn,m)&&!l.has(u),`summary values for ${u}`);let g=c.get(f)??{directories:[],rows:[]},y={raw:d,id:u,prefix:h,product:f,priority:m,group:g};l.set(u,y),g.rows.push(y),c.set(f,g)}_(l.size,"empty summary");for(let[d,p]of n.entries()){let u=/^\d+\.\s+(\S+)\s*$/u.exec(p[1])?.[1],f=l.get(u);_(f&&!f.finding,`finding section ${p[1]}`);let m=e.slice(p.index,n[d+1]?.index),h=m.slice(p[0].length+1),g=new Map,y=[...h.matchAll(ni)];for(let[$,k]of y.entries()){let Ye=k[1],Gt=Ye.toLowerCase().replace(/^steps to reproduce\b.*$/u,"steps to reproduce");_(!g.has(Gt),`duplicate section ${Ye}`),g.set(Gt,{heading:Ye,body:h.slice(k.index+k[0].length,y[$+1]?.index).trim()})}_(ti.every($=>g.has($)),`missing required headers for ${u}`),_(!h.slice(0,y[0].index).trim(),`text before field headers for ${u}`);let v=g.get("title")?.body;_(v,`missing Title for ${u}`);let w={sourceId:u,_idBasis:{source:vt,row:f.raw.trim(),section:m.trim()},product:f.product,priority:f.priority,severity:Yn[f.priority],file:"unknown",line:"?"};s.has("vulnerability")&&(w.security=!0);let A=[v];for(let[$,k]of g)$==="title"||$==="code references"||($==="steps to reproduce"?w.reproduction=k.body:$==="patch"?w.recommendation=k.body:A.push($==="description"?k.body:`**${k.heading}:**
|
|
32
|
+
${k.body}`));w.description=A.join(`
|
|
32
33
|
|
|
33
|
-
`)
|
|
34
|
-
|
|
35
|
-
`),
|
|
36
|
-
`)}var Zi=/(?:^|[ \t])(\d{1,9})\)(?=[ \t]|$)/gu,qi=/^\d{1,9}\)(?=[ \t]|$)/u;function Vn(t){let e=[...t.matchAll(Zi)];if(e.length===0||e[0].index!==0)return null;let n=[];for(let[i,r]of e.entries()){let o=Number(r[1]);if(i>0&&o<=n[i-1].number)return null;let s=t.slice(r.index+r[0].length,e[i+1]?.index).trim();if(!s)return null;n.push({number:o,step:s})}return n}var Gn=/^[ \t]*(?:\d+[.)]|[-*+])\s+/u;function Yi(t){let e=[];for(let n of t.split(`
|
|
37
|
-
`))Gn.test(n)?e.push({ref:n.replace(Gn,"").trim(),note:[]}):e.length>0&&n.trim()&&e.at(-1).note.push(n.trim());if(e.length===0){let n=t.split(`
|
|
38
|
-
`).map(o=>o.trim()).filter(Boolean),i=n.findIndex(o=>G(o)!==null);if(i===-1&&n.length!==1)return[];let r=i===-1?0:i;e.push({ref:n[r],note:n.filter((o,s)=>s!==r)})}return e.filter(n=>n.ref)}function Ji({ref:t,note:e}){let{file:n,line:i,locationLink:r,linked:o}=Kn(t),s={file:n||"unknown",line:i};r&&o&&(s.url=r);let a=e.join(`
|
|
39
|
-
`);return a&&(s.text=a),s}function Qi(t,e,n){let i=[t];return e.details&&i.push(e.details),e.evidence&&!n&&i.push(`**Evidence:**
|
|
40
|
-
${e.evidence}`),e.impact&&i.push(`**Impact:** ${e.impact}`),i.join(`
|
|
34
|
+
`),oi(f,w,g.get("code references").body,a),f.finding=w}return _([...l.values()].every(d=>d.finding),"missing finding sections"),[...c].map(([d,p])=>{let u={github:p.github,directory:ii(p.directories)},f=p.rows.map(({finding:m})=>({...m,repo:{github:p.github}}));return{displayName:d,data:{type:"security",source:vt,product:d,repo:u,findings:f}}})}function Jn(t){let e=si(t);return e===null?null:e.length===1?e[0].data:{type:"security",source:vt,findings:e.flatMap(({data:n})=>n.findings)}}var ai=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Qn(t){let e=ci(t);if(!e)return null;let{severity:n,description:o,location:r,file:i,line:s}=e;return r?{severity:n,description:o,location:r}:{severity:n,description:o,file:i,line:s}}function ci(t){let e=t.indexOf(`
|
|
35
|
+
`),n=(e===-1?t:t.slice(0,e)).trim();if(!n)return null;let o=e===-1?"":t.slice(e+1),{sectionsText:r,metaText:i}=li(o),s=di(r),c=ui(i),{file:a,line:l,locationLink:d}=pi(s.location||""),p=(c.severity||"").toLowerCase();return{severity:ai.has(p)?p:"medium",description:fi(n,s),location:d,file:a||"unknown",line:l}}function li(t){let e=/^---\s*$/mu,n=e.exec(t);if(!n)return{sectionsText:t,metaText:""};let o=t.slice(0,n.index).trim(),r=t.slice(n.index+n[0].length).replace(/^\n/u,""),i=e.exec(r),s=i?r.slice(0,i.index):r;return{sectionsText:o,metaText:s}}function di(t){let e={},n=t.split(/^## /mu);for(let o=1;o<n.length;o++){let r=n[o],i=r.indexOf(`
|
|
36
|
+
`),s=(i===-1?r:r.slice(0,i)).trim().toLowerCase(),c=(i===-1?"":r.slice(i+1)).trim();s&&(e[s]=c)}return e}function ui(t){let e={};for(let n of t.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[n[1].trim().toLowerCase()]=n[2].trim();return e}function pi(t){let e="",n="?",o="",r=t.match(/\[([^\]]+)\]\(([^)]+)\)/u);if(r){e=r[1].trim(),o=r[2];let s=r[2].match(/#L(\d+)/u);s&&(n=s[1])}else e=t.trim(),o=t.trim();let i=e.match(/^(.+):(\d+)$/u);return i&&(e=i[1],n==="?"&&(n=i[2])),{file:e,line:n,locationLink:o}}function fi(t,e){let n=[t];return e.details&&n.push(e.details),e.impact&&n.push(`Impact: ${e.impact}`),e["reproduction steps"]&&n.push(`Reproduction: ${e["reproduction steps"]}`),mi(n.join(`
|
|
41
37
|
|
|
42
|
-
`)}function
|
|
43
|
-
`)){let
|
|
38
|
+
`))}function mi(t){return t.replaceAll("**","")}var hi=new Set([...ft,"informative"]);function nr(t){let e=S(t).trim();if(!e.startsWith("# "))return null;let o=Re(e,/^# /gmu).slice(1).filter(r=>r.trim().length>0).map(r=>gi(r)).filter(Boolean);return o.length===0?null:{type:"security",source:"claude-security",findings:o}}function gi(t){let{title:e,body:n}=pe(t);if(!e)return null;let{sectionsText:o,metaText:r}=yi(n),i=bi(o),s=Object.fromEntries([...r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu)].map(y=>[y[1].trim().toLowerCase(),y[2].trim()])),c=xi(i.evidence||""),{file:a,line:l,locationLink:d}=rr(i.location||c[0]?.ref||""),p=(s.severity||"").toLowerCase(),u=hi.has(p)?p:"medium",f=Ei(e,i,c.length>0),m={file:a||"unknown",line:l,severity:u,description:f};d&&(m.location=d),c.length>0&&(m.evidence=c.map($i)),i["reproduction steps"]&&(m.reproduction=wi(i["reproduction steps"])),i["recommended fix"]&&(m.recommendation=i["recommended fix"]),s.repository&&(m.repo={github:s.repository}),s.branch&&(m.branch=s.branch),s["date created"]&&(m.dateCreated=s["date created"]),s.status&&(m.status=s.status),s.category&&(m.category=s.category);let h=t.indexOf(`
|
|
39
|
+
# `),g=Qn(h===-1?t:t.slice(0,h+1));return g&&(m._idBasis=g),E(m)}function yi(t){let e=/^---\s*$/mu,n=e.exec(t);if(!n)return{sectionsText:t,metaText:""};let o=t.slice(0,n.index).trim(),r=t.slice(n.index+n[0].length).replace(/^\n/u,""),i=e.exec(r),s=i?r.slice(0,i.index):r;return{sectionsText:o,metaText:s}}function bi(t){let e=t.split(/^## /mu).slice(1).map(n=>pe(n));return Object.fromEntries(e.filter(n=>n.title).map(n=>[n.title.toLowerCase(),n.body.trim()]))}function rr(t){let e="",n="?",o="",r=Y(t);if(r){e=r.label.trim(),o=r.url.trim();let s=o.match(/#L(\d+)(?:-L?(\d+))?/u);s&&(n=s[2]?`${s[1]}-${s[2]}`:s[1])}else e=t.trim(),o=t.trim();e=Sn(e.replaceAll("`","")).trim();let i=e.match(/^(.+):(\d+)(?:\s*[-–—]\s*L?(\d+))?$/u);return i&&(e=i[1],n==="?"&&(n=i[3]?`${i[2]}-${i[3]}`:i[2])),{file:e,line:n,locationLink:o,linked:r!==null}}function wi(t){let e=t.split(`
|
|
40
|
+
`),n=e.findIndex(c=>c.trim());if(n===-1||!F.test(e[n])||e.some((c,a)=>a!==n&&F.test(c)))return t;let o=e[n].replace(/^ */u,""),r=o.replace(F,"");if(!r.trim())return t;let i=er(r)??er(o);if(i===null&&(F.test(r)||_i.test(o)))return t;let s=i===null?[r]:i.length===1?[i[0].step]:i.map(({number:c,step:a})=>`${c}. ${a}`);return e.splice(n,1,...s),e.join(`
|
|
41
|
+
`)}var vi=/(?:^|[ \t])(\d{1,9})\)(?=[ \t]|$)/gu,_i=/^\d{1,9}\)(?=[ \t]|$)/u;function er(t){let e=[...t.matchAll(vi)];if(e.length===0||e[0].index!==0)return null;let n=[];for(let[o,r]of e.entries()){let i=Number(r[1]);if(o>0&&i<=n[o-1].number)return null;let s=t.slice(r.index+r[0].length,e[o+1]?.index).trim();if(!s)return null;n.push({number:i,step:s})}return n}var tr=/^[ \t]*(?:\d+[.)]|[-*+])\s+/u;function xi(t){let e=[];for(let n of t.split(`
|
|
42
|
+
`))tr.test(n)?e.push({ref:n.replace(tr,"").trim(),note:[]}):e.length>0&&n.trim()&&e.at(-1).note.push(n.trim());if(e.length===0){let n=t.split(`
|
|
43
|
+
`).map(i=>i.trim()).filter(Boolean),o=n.findIndex(i=>Y(i)!==null);if(o===-1&&n.length!==1)return[];let r=o===-1?0:o;e.push({ref:n[r],note:n.filter((i,s)=>s!==r)})}return e.filter(n=>n.ref)}function $i({ref:t,note:e}){let{file:n,line:o,locationLink:r,linked:i}=rr(t),s={file:n||"unknown",line:o};r&&i&&(s.url=r);let c=e.join(`
|
|
44
|
+
`);return c&&(s.text=c),s}function Ei(t,e,n){let o=[t];return e.details&&o.push(e.details),e.evidence&&!n&&o.push(`**Evidence:**
|
|
45
|
+
${e.evidence}`),e.impact&&o.push(`**Impact:** ${e.impact}`),o.join(`
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
`).
|
|
47
|
-
`).trim(),b=ft({ref:pt.map(k=>l[k]).find(Boolean)??"",lineBullet:f,id:o,severity:u,identitySeverity:h,description:lo(s||o,l,d,g)}),_=l["poc status"]||l.poc||c?.pocStatus;_&&(b.pocStatus=_);let w=l["detailed report"]||(a.endsWith("report.md")?a:"");w&&(b.reportPath=w),c?.status&&(b.status=c.status);let $=c?.parent||(m?ce(m[1]):"");return $&&(b.parent=$),{id:o,finding:x(b)}}function ao(t){let e=Object.create(null);for(let{heading:n,body:i}of t){let r=n.trim().toLowerCase();r&&(e[r]=r in e?`${e[r]}
|
|
48
|
-
${i}`:i)}return e}var co=new Set([...pt,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"]);function lo(t,e,n,i){let r=[t];e.summary&&r.push(e.summary),i&&r.push(i);for(let[o,s]of Object.entries(e))!s||co.has(o)||r.push(`**${n[o]||o}:** ${s}`);return r.filter(Boolean).join(`
|
|
47
|
+
`)}function Ai(t){let e=(t||"").trim(),n="",o=/\[([^\]]+)\]\(([^)]+)\)/u.exec(e);o&&(e=o[1].trim(),n=o[2].trim());let r="",i=/#L(\d+)/u.exec(n);i&&(r=i[1]);let a=[...e.matchAll(/`([^`]+)`/gu)].map(p=>p[1].trim()).find(p=>!p.includes("(")&&(p.includes("/")||/\.\w/u.test(p)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),l=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(a);l&&(a=l[1],r||(r=l[2]));let d=/^(.+):(\d+(?:-\d+)?)$/u.exec(a);return d?(r||(r=d[2]),{file:d[1],line:r,locationLink:n}):{file:a,line:r||"?",locationLink:n}}function or({severity:t,description:e,ref:n,lineBullet:o="",id:r=""}){let i=Ai(n),s=i.file||"unknown",c=i.line==="?"&&o?o:i.line,a=i.locationLink||(s==="unknown"&&r?`piolium:${r}`:"");return a?{severity:t,description:e,location:a}:{severity:t,description:e,file:s,line:c}}function O(t){let e=((t||"").trim().split(/\s+/u)[0]||"").replaceAll(/[`*]+/gu,"");return Ce.get(e.toUpperCase())??""}function he(...t){return{severity:t.find(Boolean)||"medium",identitySeverity:t.find(e=>e&&e!=="informative")||"medium"}}function ge(t){let e=/^([CHML])-?\d+$/iu.exec((t||"").trim());return e?{C:"critical",H:"high",M:"medium",L:"low"}[e[1].toUpperCase()]:""}function _t(t){return O(/^(critical|high|medium|low|informational|informative|info)(?:[ -](?:severity|risk))?(?:[ -]findings?)?(?:\s*\(\d+\))?$/iu.exec((t||"").trim())?.[1])}function ir(t){return O(/^(critical|high|medium|low|informational|informative|info)\b/iu.exec((t||"").trim())?.[1])}function De(t){return/^variants?\s*(?:\(\d+\))?\s*:?$/iu.test((t||"").trim())}function Ue(t){let e=/^([CHML]-?\d{1,4}|(?:p|q|b|r|m|l|x|diff)\d{0,4}-\d{2,4})(?:-([A-Za-z0-9][\w-]*))?$/iu.exec(t||"");return e?{id:e[1].toUpperCase(),slug:e[2]||""}:null}function Be(t){return(t||"").replaceAll("-"," ")}function ye(t){let e=(t||"").trim(),n=/^\[([^\]]+)\]\([^)]*\)$/u.exec(e);return In(n?n[1]:e).toUpperCase()}function xt(t){let e=/^\[([^\]]+)\]\(([^)]+)\)\s*[:—–-]*\s*(.*)$/u.exec(t);return e?{text:e[3]?`${e[1].trim()} ${e[3].trim()}`:e[1].trim(),link:e[2].trim()}:null}function $t(t){let e=t.search(/\s/u),n=(e===-1?t:t.slice(0,e)).replace(/[:.,—–-]+$/u,""),o=Ue(n);if(!o)return null;let r=(e===-1?"":t.slice(e+1)).replace(/^[:—–-]+\s*/u,"").trim();return{id:o.id,slug:o.slug,rest:r}}function Et(t){let{text:e,link:n}=xt(t)??{text:t,link:""},o=/^\[([^\]]+)\] *(.*)$/u.exec(e);if(o){let i=Ue(o[1].trim());return i?{id:i.id,title:o[2].trim()||Be(i.slug)||i.id,link:n}:{id:o[1].trim().toUpperCase(),title:o[2].trim(),link:n}}let r=$t(e);return r?{id:r.id,title:r.rest||Be(r.slug)||r.id,link:n}:{id:"",title:e.trim(),link:n}}function sr(t){let e={},n=i=>{let s=i.exec(t||"")?.[1];return s===void 0?"":(/`([^`]+)`/u.exec(s)?.[1]??s.split(/\s+/u)[0]??"").trim()},o=n(/^\s*(?:[-*] +)?\*\*Target:?\*\*\s*(.*)$/imu);bt(o)&&(e.repo=o);let r=n(/^\s*(?:[-*] +)?\*\*Commit[^:*]*:?\*\*\s*(.*)$/imu);return q(r)&&(e.commitHash=r),e}var At=["key code reference","key code","code reference","location","affected file","file","path"];function Fe(t){return{id:ye(t.id||""),title:H(t.title),severity:H(t.severity),pocStatus:H(t["poc status"]||t.poc),status:H(t.status),parent:ye(H(t.parent||"")),location:H(t.location)}}function Pe(t,e=""){let{severity:n,identitySeverity:o}=he(O(t.severity),e,ge(t.id)),r=kt({ref:t.location||"",id:t.id,severity:n,identitySeverity:o,description:pt(t.title||t.id)});for(let i of["pocStatus","status","parent"])t[i]&&(r[i]=t[i]);return E(r)}function kt({ref:t,lineBullet:e="",id:n,severity:o,identitySeverity:r,description:i}){let{file:s,line:c,locationLink:a}=An(t),l={file:s||"unknown",line:c==="?"&&e?e:c,severity:o,description:i};return a?l.location=a:l.file==="unknown"&&n&&(l.location=`piolium:${n}`),l._idBasis=or({severity:r,description:i,ref:t,lineBullet:e,id:n}),l}function St(t,e,n){let o=[];for(let r of t.split(`
|
|
48
|
+
`)){let i=/^\s{0,3}(?:[-*+]|\d{1,3}[.)])\s+(.+)$/u.exec(r);if(!i)continue;let s=i[1].trim();if(/^\*\*[^:*]+:\*\*/u.test(s))continue;let c=xt(s),a=c?.link??"";if(c)s=c.text;else{let g=/^\*\*([^*]+)\*\*\s*[:—–-]*\s*(.*)$/u.exec(s);g&&(s=g[2]?`${g[1].trim()} ${g[2].trim()}`:g[1].trim())}if(/^(?:none\b|no |n\/a\b)/iu.test(s))continue;let l=$t(s),d=l?.id??"",p=s;if(l){let g=Be(l.slug);p=g&&l.rest?`${g}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
${l.rest}`:l.rest||g||l.id}let u=n.get(d),{severity:f,identitySeverity:m}=he(O(u?.severity),e,ge(d)),h={file:"unknown",line:"?",severity:f,description:pt(p)};d?h.location=`piolium:${d}`:a&&(h.location=a),a.endsWith("report.md")&&(h.reportPath=a);for(let g of["pocStatus","status","parent"])u?.[g]&&(h[g]=u[g]);o.push({id:d,finding:E(h,m)})}return o}function It(t,e,n,o=""){let r=[];for(let s of fe(t)){let c=Fe(s);!c.id&&!c.title||(!c.parent&&n&&(c.parent=n),c.id&&!e.has(c.id)&&e.set(c.id,c),r.push({id:c.id,finding:Pe(c,o)}))}if(r.length>0)return r;let i=St(t,o,e);for(let s of i)n&&!s.finding.parent&&(s.finding.parent=n);return i}var ki=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]),Si=/^(?:summary of findings\b|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope\b|table of contents|contents\b|appendix|recommendation|remediation)/u;function ar(t){let{id:e}=Et(t);return!!(e&&Ue(e))}function Ii(t){let e=M(t,ue);return(e.length>0?e:M(t,T)).some(({heading:o})=>ar(o))}function cr(t){let e=S(t).trim();if(!/^# +Security Audit Report\b/mu.test(e)&&!/^## +Technical Findings Detail\s*$/imu.test(e)&&!/^## +Findings by Severity\b/imu.test(e))return null;let{head:n,subs:o}=L(e,Ie),r=Li(o),i=new Map(fe(r["summary of findings"]||"").map(Fe).filter(u=>u.id).map(u=>[u.id,u])),s=sr(n),c=[],a=new Set,l=[],d=({id:u,finding:f})=>{c.push(f),u&&a.add(u)},p=u=>{for(let f of u)d(f)};for(let[u,f]of Object.entries(r)){let m=_t(u);m||ki.has(u)||u.startsWith("findings by severity")?p(Rt(f,m,i,l)):!Si.test(u)&&Ii(f)&&p(Rt(f,ir(u),i,l))}for(let u of l)(!u.id||!a.has(u.id))&&d(u);for(let u of i.values())a.has(u.id)||d({id:u.id,finding:Pe(u)});if(c.length===0)return null;for(let u of c)s.repo&&(u.repo={github:s.repo}),s.commitHash&&!u.auditedCommit&&(u.auditedCommit=s.commitHash);return{type:"security",source:"piolium",findings:c}}function Ri(t,e,n,o){let r=[],i="";for(let{heading:s,body:c}of t){let a=_t(s);if(a)r.push(...Rt(c,a,e,n)),i="";else if(De(s))r.push(...Ti(c,e,i,n,o));else{let l=Ci(s,c,e,n,o);r.push(...l),i=l[0]?.id||i}}return r}function Ci(t,e,n,o,r){let{head:i,subs:s}=L(e,T),c=lr(t,i,n,r),a=c!==null&&!c.id&&s.some(d=>!De(d.heading)&&ar(d.heading)),l=c&&!a?[c]:[];return l.push(...Ct(s,n,o,r,c?.id||"")),l}function Ti(t,e,n,o,r){let{head:i,subs:s}=L(t,T);return o.push(...It(i,e,n,r)),Ct(s,e,o,r,"")}function Ct(t,e,n,o,r){let i=[],s="";for(let{heading:c,body:a}of t){if(De(c)){n.push(...It(a,e,r??s,o));continue}let l=lr(c,a,e,o);l&&(i.push(l),s=l.id||s)}return i}function Rt(t,e,n,o){let r=M(t,ue);if(r.length>0)return Ri(r,n,o,e);let i=Ct(M(t,T),n,o,e,null);if(i.length>0)return i;let s=fe(t).map(Fe).filter(c=>c.id||c.title);for(let c of s)!c.severity&&e&&(c.severity=e),c.id&&!n.has(c.id)?n.set(c.id,c):c.id||o.push({id:"",finding:Pe(c,e)});return s.length===0&&o.push(...St(t,e,n)),[]}function lr(t,e,n,o=""){let r=t.trim();if(!r)return null;let{id:i,title:s,link:c}=Et(r),a=n.get(i);if(!i&&s){let $=s.toLowerCase();a=[...n.values()].find(k=>k.title.toLowerCase()===$),i=a?.id??""}let{fields:l,labels:d,prose:p}=En(e),{severity:u,identitySeverity:f}=he(O(l.severity),O(a?.severity),o,ge(i)),m=/\d+/u.exec(l.line||l.lines||"")?.[0]??"",h=/\*\*Variant of:?\*\*\s*\[?([^\]\s)]+)/iu.exec(e),g=p.split(`
|
|
51
|
+
`).filter($=>!/^\s*<a\s[^>]*>\s*<\/a>\s*$/iu.test($)&&!/\*\*Variant of:?\*\*/iu.test($)).join(`
|
|
52
|
+
`).trim(),y=kt({ref:At.map($=>l[$]).find(Boolean)??"",lineBullet:m,id:i,severity:u,identitySeverity:f,description:Oi(s||i,l,d,g)}),v=l["poc status"]||l.poc||a?.pocStatus;v&&(y.pocStatus=v);let w=l["detailed report"]||(c.endsWith("report.md")?c:"");w&&(y.reportPath=w),a?.status&&(y.status=a.status);let A=a?.parent||(h?ye(h[1]):"");return A&&(y.parent=A),{id:i,finding:E(y)}}function Li(t){let e=Object.create(null);for(let{heading:n,body:o}of t){let r=n.trim().toLowerCase();r&&(e[r]=r in e?`${e[r]}
|
|
53
|
+
${o}`:o)}return e}var Mi=new Set([...At,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"]);function Oi(t,e,n,o){let r=[t];e.summary&&r.push(e.summary),o&&r.push(o);for(let[i,s]of Object.entries(e))!s||Mi.has(i)||r.push(`**${n[i]||i}:** ${s}`);return r.filter(Boolean).join(`
|
|
53
54
|
|
|
54
|
-
`)
|
|
55
|
+
`)}var Ni=["finding_url","repository","title","description","severity","configured_scan_id","relevant_paths"];function Bi(t){let e=[],n=[],o="",r=!1;for(let i=0;i<t.length;i++){let s=t[i];r?s==='"'?t[i+1]==='"'?(o+='"',i++):r=!1:o+=s:s==='"'?r=!0:s===","?(n.push(o),o=""):s===`
|
|
56
|
+
`||s==="\r"?(n.push(o),e.push(n),n=[],o="",s==="\r"&&t[i+1]===`
|
|
57
|
+
`&&i++):o+=s}for((o!==""||n.length>0)&&(n.push(o),e.push(n));e.length>0&&e.at(-1).length===1&&e.at(-1)[0]==="";)e.pop();return e}function Di(t,e){return e.map(n=>{let o=Object.create(null);return t.forEach((r,i)=>{o[r]=n[i]??""}),o})}function Tt(t){let e=Bi(t);if(e.length<2)throw new Error("Codex CSV: empty or missing header row");let[n,...o]=e;for(let s of Ni)if(!n.includes(s))throw new Error(`Codex CSV: missing required column "${s}"`);let r=Map.groupBy(Di(n,o).filter(s=>s.configured_scan_id),s=>s.configured_scan_id);if(r.size===0)throw new Error("Codex CSV: no rows with a configured_scan_id");let i=[];for(let[s,c]of r){let a=new Set(c.map(p=>p.repository).filter(Boolean));if(a.size>1)throw new Error(`Codex CSV: scan ${s} contains multiple repositories: ${[...a].join(", ")}`);let d=`${[...a][0]||"unknown-repo"}:${s.replace(/^[^:]+:/u,"")}`;i.push({displayName:d,data:{type:"security",source:"codex-security",findings:c.map(Ui)}})}return i}function Ui(t){let e=t.relevant_paths.split(" | ").map(r=>r.trim()).find(Boolean)||"unknown",n=[t.title,t.description].filter(Boolean).join(`
|
|
55
58
|
|
|
56
|
-
`),imported:d}):c.comment=d}else if(a[l]!==void 0&&a[l]!==d){let p=u=>l==="flagged"?u?"flagged":"not flagged":u;n.push({id:r,property:l,local:p(a[l]),imported:p(d)})}else c[l]=d}return{entries:i,conflicts:n}}async function $o(t,e,n,i,r){r?.throwIfAborted();let{entries:o,conflicts:s}=xo(t,e);if(s.length===0)return o;let a=await i(s,n,{title:"Triage conflicts on import",intro:"disagree with stored triage on",trailingNote:"Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.",importedSideLabel:"Apply imported"});if(r?.throwIfAborted(),!a)throw new Error("Triage conflict resolution was cancelled.");for(let c of s){let l=a[`${c.id}:${c.property}`];if(!["local","imported"].includes(l))throw new Error("Resolve every triage conflict before importing.");l==="imported"&&(o[c.id][c.property]=t[c.id][c.property])}return o}function Eo(t,e){let n=[],i={entries:{},expected:{}};for(let[r,o]of Object.entries(t)){let s={entries:{...i.entries,[r]:o},expected:{...i.expected,[r]:e[r].version}};if(new TextEncoder().encode(JSON.stringify(s)).length<=262144){i=s;continue}if(Object.keys(i.entries).length===0)throw new Error("This triage entry is too large to import.");n.push(i),i={entries:{[r]:o},expected:{[r]:e[r].version}}}return Object.keys(i.entries).length>0&&n.push(i),n}async function _t(t,{api:e,path:n,ids:i=Object.keys(t),importedIds:r=new Set,lookup:o=new Map,resolveConflicts:s,signal:a}){i=i.filter(c=>Object.hasOwn(t,c)&&!r.has(c));for(let c=0;c<i.length;c+=200){let l=i.slice(c,c+200);for(let d=0;d<5&&l.length>0;d++){a?.throwIfAborted();let{snapshots:p}=await e.send(n,{findingIds:l}),u=Object.fromEntries(l.map(f=>[f,t[f]])),h=await $o(u,p,o,s,a);for(let f of Eo(h,p)){if(a?.throwIfAborted(),(await e.send(n,f)).conflict)break;Object.keys(f.entries).forEach(m=>r.add(m))}l=l.filter(f=>!r.has(f))}if(l.length>0)throw new Error("Stored triage keeps changing. Retry to resolve it against the latest values.")}}function ar(t){if(typeof t!="string")return{ok:!0,path:null};if(/\p{Cc}/u.test(t)||t.includes("\\")||t!==t.trim())return{ok:!1};let e=[];for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."||i!==i.trim())return{ok:!1};e.push(i)}let n=e.join("/");return n.length>500?{ok:!1}:{ok:!0,path:n===""?null:n}}async function cr(t,e){let n=new Uint8Array(await t.arrayBuffer());return be(n)?e({tryPassword:i=>Qe(n,i)}):n[0]===31&&n[1]===139?Qe(n):ve(new TextDecoder("utf-8",{fatal:!0}).decode(n))}async function lr(t,e){let n=new Map,i=[];for(let s of t.reports){if(typeof s?.name!="string"||!s.name||typeof s.content!="string")throw new Error("Every report must have a name and content.");let a=vt(s.content,s.name);if(!a.data)throw new Error(`${s.name}: ${a.reason??"Unsupported report"}`);let c=oe(a.data),l=c??oe(s)??oe({repo:{github:t.repoUrls?.[s.name]}}),d=e.find(h=>h.fullName.toLowerCase()===l?.toLowerCase())?.repoId??null,p=ar(a.data.repo?.directory);if(!p.ok)throw new Error(`${s.name}: invalid repository directory`);let u=a.format==="links"?[]:(await rr(s.content,s.name))?.findings??[];for(let h of u)h.id&&n.set(h.id,h);i.push({...s,repoId:d,directory:p.path??"",github:l,embedded:c,ids:[...new Set(u.map(h=>h.id).filter(Boolean))],uploaded:null})}let r=Object.create(null);if(t.triage!=null&&(typeof t.triage!="object"||Array.isArray(t.triage)))throw new Error("Invalid workspace triage.");for(let[s,a]of Object.entries(t.triage??{})){if(!n.has(s))continue;let c=Ne(a);if(!c)continue;let{ignoredReports:l,...d}=c;Object.keys(d).length!==0&&(r[s]=d)}let o=[];for(let s of t.bundleBlobs??[]){let a=Uint8Array.fromBase64(s.data),c=`sha512-${new Uint8Array(await crypto.subtle.digest("SHA-512",a)).toBase64()}`;if(c!==s.integrity)throw new Error(`${s.name}: bundle integrity mismatch`);o.push({name:s.name,integrity:c,bytes:a,uploaded:null})}return{name:t.workspace.name.slice(0,100),reports:i,bundles:o,triage:r,lookup:n,references:t.bundles??[],team:null,completed:new Set,importedIds:new Set}}function Ue(t,e,n){async function i(r,o,s={}){n?.throwIfAborted();let a=await t(r,{credentials:"same-origin",signal:n,...o===void 0?{}:{method:"POST",body:o instanceof File?o:JSON.stringify(o)},headers:{...o instanceof File?{}:{"content-type":"application/json"},"x-csrf-token":e.csrfToken,...s}});if(n?.throwIfAborted(),a.status===409)return{conflict:!0};if(!a.ok)throw new Error(`Import request failed (HTTP ${a.status}). You can retry the remaining steps.`);let c=await a.json();return n?.throwIfAborted(),c}return{send:i}}async function So(t,e,n,i,r,o){if(t.bundles.length===0&&t.references.length===0)return;let s=r??(await n.send("/api/admin/bundles")).bundles,a=new Set(t.bundles.map(l=>l.uploaded.id));if([...a].some(l=>!s.some(d=>d.id===l)))throw new Error("Could not verify the uploaded source bundles. Retry the import.");let c=new Set(t.references);for(let l of s){if(!a.has(l.id)&&!c.has(l.integrity))continue;let d=!o.has(l.repoId),p=d?e:l.repoId;d&&await i(`bundle-repo:${l.id}:${p}`,()=>n.send("/api/admin/bundles/set-repo",{bundleId:l.id,repoId:p}));let u=d?"":l.repoDirectory??"";await i(`repo:${p}:${u}`,()=>n.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:p,path:u}))}}async function ur(t,{api:e,session:n,defaultRepo:i,includeTriage:r,resolveConflicts:o,signal:s,progress:a=()=>{}}){if(n?.role!=="admin"||!n.csrfToken)throw new Error("An administrator session is required.");if(!t.name.trim()||t.name.trim().length>100)throw new Error("Enter a team name of up to 100 characters.");if(r)for(let[u,h]of Object.entries(t.triage)){if(!u||u.length>100)throw new Error(`Triage finding IDs must be between 1 and ${100} characters. Choose Skip triage to import the files without it.`);if(Be(h)==="invalid")throw new Error(`Triage for ${u} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}s?.throwIfAborted();let c=null;if(t.bundles.length===0){let u=new Set(t.references);c=u.size>0?(await e.send("/api/admin/bundles")).bundles.filter(h=>u.has(h.integrity)):[]}if(t.reports.length===0&&t.bundles.length===0&&c.length===0)throw new Error(t.references.length>0?"None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.":"This workspace contains no report or bundle files.");let l=new Set((await e.send("/api/admin/repositories/browsable")).repos.map(u=>u.repoId));for(let u of t.reports){if(u.embedded&&!l.has(u.repoId))throw new Error(`Connect ${u.embedded} in Repositories before importing ${u.name}.`);if(!l.has(u.repoId)&&!l.has(i))throw new Error(`Choose an active repository for ${u.name}.`)}if((t.bundles.length>0||c.some(u=>!l.has(u.repoId)))&&!l.has(i))throw new Error("Choose an active repository for the source bundles.");let d=()=>s?.throwIfAborted(),p=async(u,h)=>{d(),t.completed.has(u)||(await h(),t.completed.add(u))};if(d(),!t.team){let u=await e.send("/api/admin/teams",{name:t.name.trim()});if(u.conflict)throw new Error("A team already has this name. Choose another name.");t.team=u}await p("member",()=>e.send("/api/admin/teams/set-member",{teamId:t.team.id,userId:n.id,security:!0,dependencies:!0}));for(let u of t.bundles)d(),a(`Importing ${u.name}\u2026`),u.uploaded||(u.uploaded=await e.send("/api/admin/bundles",new File([u.bytes],u.name),{"x-bundle-filename":encodeURIComponent(u.name),"x-repo-id":String(i)}));await So(t,i,e,p,c,l);for(let u of t.reports){d(),a(`Importing ${u.name}\u2026`);let h=l.has(u.repoId)?u.repoId:i;if(!u.uploaded){let g=await e.send("/api/admin/reports",new File([u.content],u.name),{"x-report-filename":encodeURIComponent(u.name),"x-repo-id":String(h),"x-repo-directory":encodeURIComponent(u.directory)});if(g.conflict)throw new Error(`Could not reuse the stored report ${u.name}. Retry the import.`);u.uploaded=g}let f=u.uploaded;l.has(f.repoId)||await p(`report-repo:${f.id}:${h}:${u.directory}`,async()=>{if((await e.send("/api/admin/reports/set-repo",{reportId:f.id,repoId:h,directory:u.directory})).conflict)throw new Error(`Could not assign the stored report ${u.name} to its repository.`);f.repoId=h,f.repoDirectory=u.directory});let m=f.repoDirectory??"";await p(`repo:${f.repoId}:${m}`,()=>e.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:f.repoId,path:m})),r&&await _t(t.triage,{api:e,resolveConflicts:o,signal:s,ids:u.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(u.uploaded.id)}/import-triage`}),await p(`publish:${u.uploaded.id}`,()=>e.send("/api/admin/reports/set-visible",{reportId:u.uploaded.id,visible:!0}))}return t.team}function dr(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();return{get locked(){return e()},unlock:n=>t.unlockEncryption(n),async read({signal:n}={}){let i=!1,r=t.onVaultStateChange(()=>{i=!0}),o=()=>{if(n?.throwIfAborted(),e()||i)throw new Error("Local data was locked or changed. Unlock it and import triage again.")};try{o();let s=await t.readTriageBlob();return o(),s}finally{r()}}}}function De(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();async function n(){let r=JSON.parse(await t.hydrateKey("deepview.workspaces")||"[]");return(Array.isArray(r)?r:r.workspaces??[]).filter(o=>typeof o.id=="string"&&typeof o.name=="string")}async function i(r,o){let s=!1,a=[t.onVaultStateChange,t.onFileMutated,t.onBundleMutated].map(l=>l(()=>{s=!0})),c=()=>{if(o?.throwIfAborted(),e()||s)throw new Error("Local data was locked or changed. Unlock it and select the workspace again.")};try{c();let l=await r(c);return c(),l}finally{a.forEach(l=>l())}}return{get locked(){return e()},unlock:r=>t.unlockEncryption(r),list:({signal:r}={})=>i(async()=>(await n()).map(o=>({id:o.id,name:o.name})),r),read:(r,{signal:o}={})=>i(async s=>{let a=(await n()).find(f=>f.id===r);if(!a)throw new Error("This local workspace no longer exists.");let c=JSON.stringify(a),l=JSON.parse(await t.hydrateKey("deepview.repoUrls")||"{}"),d=[];for(let f of a.reports??[]){s();let m=await t.withStoredItem("report",f,()=>t.readFile(f));s(),d.push({name:f,content:m,...l[f]?{repo:{github:l[f]}}:{}})}let p=await t.listBundles(),u=[];for(let f of a.bundles??[]){s();let m=p.find(b=>b.integrity===f);if(!m)continue;let g=await t.withStoredItem("bundle",f,()=>t.readBundle(f));s(),u.push({integrity:f,name:m.name,data:g.toBase64()})}let h=await t.readTriageBlob()??{};if(JSON.stringify((await n()).find(f=>f.id===r))!==c)throw new Error("The local workspace changed. Select it again.");return{version:1,workspace:{id:r,name:a.name,privateKey:""},reports:d,bundles:a.bundles??[],bundleBlobs:u,triage:h,repoUrls:l}},o)}}function Ao(t,e){if(customElements.get("managed-admin-import"))return;class n extends t{static styles=[W(jt),W(Vt)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error="",this._message="",this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId="",this._triage="",this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),this._drag=!0)},this._drop=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),r.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...r.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId="",!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage)&&(this._operation?.abort(),this._message="",this._error=this._importingTriage?"Local data changed or was locked. Import triage again to continue.":"Local data changed or was locked. Choose the workspace again."))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener("dragover",this._over),this.addEventListener("drop",this._drop),globalThis.addEventListener("blur",this._blur),globalThis.addEventListener("storage",this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener("dragover",this._over),this.removeEventListener("drop",this._drop),globalThis.removeEventListener("blur",this._blur),globalThis.removeEventListener("storage",this._localChanged),super.disconnectedCallback()}updated(r){r.has("session")&&(this._role!=="admin"||r.get("session")?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(r){if(this._busy||this._role!=="admin")return;let o=this._operation=new AbortController,s=AbortSignal.any([o.signal,this.appState.sessionController.signal]);this._busy=!0,this._error="";try{await r(s),s.throwIfAborted()}catch(a){s.aborted||(this._error=String(a?.message??a))}finally{this._operation===o&&(this._busy=!1)}}async _loadCatalog(){if(this._role==="admin")try{await this._loadCollection("workspace-import:catalog","import options",async r=>{let o=Ue(e,this.session,r),[s,a,c]=await Promise.all([o.send("/api/admin/reports"),o.send("/api/admin/teams"),o.send("/api/admin/bundles")]);return{repos:s.repos,teams:a.teams,bundles:c.bundles}},r=>{this._catalog=r})}catch(r){this._error=String(r?.message??r)}}_browse(){let r=document.createElement("input");r.type="file",r.multiple=!0,r.accept=".enc,.gz,.json",r.addEventListener("change",()=>{this._files.push(...r.files),this._nextFile()},{once:!0}),r.click()}async _prepare(r,o){if(!r)return;if(this._catalog||await this._loadCatalog(),o.throwIfAborted(),!this._catalog)throw new Error("Could not load repositories. Try again.");let s=await lr(r,this._catalog.repos);o.throwIfAborted();let a=new Set(this._catalog.teams.map(p=>p.name)),c=s.name||"Imported workspace",l=2;for(;a.has(s.name);){let p=` (${l++})`;s.name=c.slice(0,100-p.length)+p}let d=new Set(s.reports.map(p=>p.repoId).filter(p=>p!=null));this._repo=d.size===1?[...d][0]:null,this._triage=Object.keys(s.triage).length>0?"":"skip",this._plan=s,this._message=""}async _nextFile(){if(this._files.length===0||this._busy)return;let r=this._files.shift();this._local=!1,this._plan=null,await this._action(async o=>{let s=await cr(r,this.promptPassword);o.throwIfAborted(),await this._prepare(s,o)})}async _unlock(r,o){this._unlocking=!0;try{return!r.locked||await r.unlock({signal:o})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async r=>{let o=De(this.localDeps);await this._unlock(o,r)&&(r.throwIfAborted(),this._workspaces=await o.list({signal:r}))})}async _readLocal(){if(!this._localId)return;let r=this._localId;this._local=!0,this._plan=null,await this._action(async o=>{let s=De(this.localDeps);if(await this._unlock(s,o)){this._readingLocal=!0;try{await this._prepare(await s.read(r,{signal:o}),o)}finally{this._readingLocal=!1}}})}async _import(){!this._plan||!this._triage||!this._csrf||(await this._action(async r=>{if(this._local&&De(this.localDeps).locked)throw new Error("Unlock local data and choose the workspace again.");let o=this._plan,s=["teams","reports","bundles","history","workspace-import","scan-sources","repo-impact"];try{let a=await this.appState.mutate(()=>ur(o,{api:Ue(e,this.session,r),session:this.session,defaultRepo:this._repo,includeTriage:this._triage==="include",resolveConflicts:this.resolveConflicts,signal:r,progress:c=>{this._message=c}}),s);this._catalog.teams.push(a),this._message=`Imported into ${a.name}.`,this._plan=null}finally{this.appState.invalidate(s),o.team&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async r=>{this._importingTriage=!0,this._message="";let o=new Set,s=["reports","history"];try{let a=dr(this.localDeps);if(!await this._unlock(a,r))return;this._readingLocal=!0;let c;try{c=await a.read({signal:r})}finally{this._readingLocal=!1}let l=await sr(c,{api:Ue(e,this.session,r),session:this.session,resolveConflicts:this.resolveConflicts,signal:r,importedIds:o,confirmImport:async d=>(await this.confirmTriageImport({...d,signal:r}))?.confirmed===!0});if(r.throwIfAborted(),l===null)return;this._message=l?`Imported triage for ${l} finding${l===1?"":"s"}.`:"No local triage matches findings in managed reports."}finally{this._importingTriage=!1,this.appState.invalidate(s),o.size>0&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}})}render(){if(this._role!=="admin")return y;let r=this._plan,o=r?Object.keys(r.triage).length:0,s=new Set([...r?.references??[],...r?.bundles.map(l=>l.integrity)??[]]),a=(this._catalog?.bundles??[]).filter(l=>s.has(l.integrity)),c=r?.references.filter(l=>!r.bundles.some(d=>d.integrity===l)).length??0;return v`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${Pt("manage-import",this._role,this.allowShare)}<h1>Import</h1><section class="triage-import" aria-label="Local triage"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?"dragging":""}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?v`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${l=>{this._localId=l.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(l=>v`<option value="${l.id}">${l.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?v`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:y}</section>`:y} ${r?v`<section class="import-preview" aria-label="Import options">${r.team?v`<p>Team ${r.team.name} has been created. Retry continues its remaining import steps.</p>`:y} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${r.name}" ?disabled="${this._busy||!!r.team}" @input="${l=>{r.name=l.target.value,this.requestUpdate()}}"><p>${r.reports.length} reports / links · ${s.size} source bundles · ${o} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??"")}" ?disabled="${this._busy||!!r.team}" @change="${l=>{this._repo=l.target.value?Number(l.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(l=>v`<option value="${String(l.repoId)}" ?selected="${this._repo===l.repoId}">${l.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${r.reports.map(l=>v`<li>${l.name}<span>${l.github??"Uses selected repository"}${l.embedded&&l.repoId==null?" \u2014 connect this repository first":""}</span></li>`)}</ul>${a.length>0?v`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${a.map(l=>v`<li>${l.filename}<span>${l.repoFullName?`${l.repoFullName}${l.repoDirectory?`/${l.repoDirectory}`:""}`:"Uses selected repository"}</span></li>`)}</ul>`:y} ${c?v`<p>${c} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:y} ${o?v`<fieldset ?disabled="${this._busy||!!r.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage==="include"}" @change="${()=>{this._triage="include"}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage==="skip"}" @change="${()=>{this._triage="skip"}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:y} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?"Importing\u2026":r.team?"Retry remaining import":"Import workspace"}</button></section>`:y} ${this._message?v`<p role="status">${this._message}</p>`:y} ${this._error?v`<p class="error" role="alert">${this._error}${this._catalog?y:v`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:y} ${this._files.length>0&&!this._busy?v`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:y}</div>`}}customElements.define("managed-admin-import",n)}export{Ao as registerWorkspaceImport};
|
|
59
|
+
`),o={id:t.finding_url,file:e,line:"?",severity:(t.severity||"medium").toLowerCase(),description:n,repo:{github:t.repository}};return t.commit_hash&&(o.commitHash=t.commit_hash),t.detected_at&&(o.detectedAt=t.detected_at),t.committed_at&&(o.committedAt=t.committed_at),E(o)}var Pi=[["deepview-md",qn],["markdown-generic",Jn],["deepsec",Mn],["piolium",cr],["claude-security",nr]];function Lt(t){return Array.isArray(t?.findings)?t.findings:Array.isArray(t?.groups)?t.groups:null}function dr(t,e){return typeof e=="string"&&/\.csv$/iu.test(e)?"codex":ze(t).format}function ze(t){let e;try{let n=JSON.parse(t);if(Lt(n)){for(let o of ur(Lt(n)))E(o);return{data:n,format:"json",reason:null}}return{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(n){e=n}for(let[n,o]of Pi)try{let r=o(t);if(r)return{data:r,format:n,reason:null}}catch(r){if(n!=="markdown-generic")throw r;return{data:null,format:n,reason:r.message}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}function ur(t){return t.flat().filter(e=>e&&typeof e=="object")}async function zi(t){for(let o of t)E(o);let e=t.filter(o=>!o.id);if(e.length===0)return;let n=await Promise.all(e.map(yn));e.forEach((o,r)=>{n[r]&&(o.id=n[r])})}async function He(t){let{data:e,format:n}=ze(t);if(!e)return null;let o=ur(Lt(e));return await zi(o),{format:n,data:e,findings:o}}function Q(t,e){if(typeof t!="string")return!1;let n=t.replaceAll("\\","/");return n.startsWith(`${e}/`)||n.includes(`/${e}/`)}function Mt(t){let e=!1;for(let n of t){for(let o of n.groups??[])for(let r of o){if(Q(r.file,"node_modules"))return"node_modules";Q(r.file,"vendor")&&(e=!0)}for(let o of Object.keys(n.tree??{})){if(Q(o,"node_modules"))return"node_modules";Q(o,"vendor")&&(e=!0)}}return e?"vendor":"dependencies"}function fr(t){return t==="inprogress"||t==="fixed"||t==="invalid"||t==="deleted"||t==="ignored"?t:void 0}function be(t){if(t)return fr(t.triage)??(t.deleted?"deleted":void 0)}function Hi(t){return t?!t.color&&!be(t)&&!t.comment&&!t.fix&&!(t.ignoredReports&&t.ignoredReports.length>0)&&t.flagged===void 0:!0}function Ot(t,e){return Array.isArray(t?.scopedIgnoredReports)&&t.scopedIgnoredReports.includes(e)}function N(t){if(!t||typeof t!="object")return;let e=t,n={};typeof e.color=="string"&&e.color&&(n.color=e.color);let o=fr(e.triage)??(e.deleted?"deleted":void 0);if(o&&(n.triage=o),typeof e.comment=="string"&&e.comment&&(n.comment=e.comment),typeof e.fix=="string"&&e.fix&&(n.fix=e.fix),typeof e.flagged=="boolean"&&(n.flagged=e.flagged),Array.isArray(e.ignoredReports)){let r=e.ignoredReports.filter(i=>typeof i=="string"&&i.length>0);r.length>0&&(n.ignoredReports=r)}if(Array.isArray(e.scopedIgnoredReports)&&n.ignoredReports){let r=[...new Set(e.scopedIgnoredReports.filter(i=>typeof i=="string"&&n.ignoredReports.includes(i)))];r.length>0&&(n.scopedIgnoredReports=r)}return Hi(n)?void 0:n}function pr(t,e){let n=t??[],o=e??[];if(n.length!==o.length)return!1;if(n.length===0)return!0;let r=new Set(n);for(let i of o)if(!r.has(i))return!1;return!0}function ji(t,e){let n=t??{},o=e??{};return(n.color??"")===(o.color??"")&&(be(n)??"")===(be(o)??"")&&(n.comment??"")===(o.comment??"")&&(n.fix??"")===(o.fix??"")&&n.flagged===o.flagged&&pr(n.ignoredReports,o.ignoredReports)&&pr(n.scopedIgnoredReports,o.scopedIgnoredReports)}function Nt(t,e,n){let o=t.get(e),r=N({...o,...n});return r===void 0?t.delete(e):ji(o,r)?!1:(t.set(e,r),!0)}function Bt(t,e,n,o,r=!1){let i=new Set(t.get(e)?.ignoredReports??[]);o?i.add(n):i.delete(n);let s=new Set(t.get(e)?.scopedIgnoredReports??[]);return o&&r&&s.add(n),Nt(t,e,{ignoredReports:i.size>0?[...i]:void 0,scopedIgnoredReports:[...s]})}function Dt(t,e){return!(t.isApp??mt(t,t._source??t.source))&&Q(t.file,t._depsDirectory??e??Mt([{groups:[[t]]}]))}function Vi(t,e){if(![...t.values()].some(o=>o?.ignoredReports?.length))return!1;let n=!1;for(let o of e){let r=Mt([o]),i=(o.groups??[]).flat(),s=a=>({...a,_source:a._source??a.source??o.source}),c=new Set(i.filter(a=>Dt(s(a),r)).map(a=>a.id??String(a._id)));for(let a of i){let l=a.id??String(a._id),d=a._reportName??o.name??o.fileName??"",p=t.get(l);p?.ignoredReports?.includes(d)&&(Ot(p,d)||Dt(s(a),r)||(be(p)||(n=Nt(t,l,{triage:"ignored"})||n),c.has(l)||(n=Bt(t,l,d,!1)||n)))}for(let a of i){if(!Dt(s(a),r))continue;let l=a.id??String(a._id),d=a._reportName??o.name??o.fileName??"";t.get(l)?.ignoredReports?.includes(d)&&(n=Bt(t,l,d,!0,!0)||n)}}return n}async function Gi(t,e){let n=new Set(Object.values(t??{}).flatMap(r=>Array.isArray(r?.ignoredReports)?r.ignoredReports.filter(i=>typeof i=="string"&&!Ot(r,i)):[])),o=[];for(let r of n){let i;try{let s=await e(r);if(typeof s!="string")continue;i=await He(s)}catch{continue}i&&o.push({...i.data,name:r,groups:[i.findings]})}return o}async function mr(t,e){if(t!=null&&(typeof t!="object"||Array.isArray(t)))return{entries:t,changed:!1};let n=new Map(Object.entries(t??{})),o=await Gi(t,e),r=Vi(n,o);return{entries:Object.fromEntries(n),changed:r}}var Wi=new TextEncoder,Ki=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});function je(t){if(typeof t!="string")throw new TypeError(`encodeUtf8 expects a string, got ${typeof t}`);if(!t.isWellFormed())throw new TypeError("encodeUtf8: input contains lone surrogates");return Wi.encode(t)}function hr(t){if(!ArrayBuffer.isView(t)&&!(t instanceof ArrayBuffer))throw new TypeError(`decodeUtf8 expects a BufferSource, got ${t===null?"null":typeof t}`);return Ki.decode(t)}async function Xi(t,{maxBytes:e}={}){let n=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"));if(e==null)return new Uint8Array(await new Response(n).arrayBuffer());let o=n.getReader(),r=[],i=0;for(;;){let{value:a,done:l}=await o.read();if(l)break;if(i+=a.length,i>e){try{await o.cancel()}catch{}throw new Error(`gunzipBytes: decompressed size exceeds ${e}-byte cap`)}r.push(a)}let s=new Uint8Array(i),c=0;for(let a of r)s.set(a,c),c+=a.length;return s}async function Ut(t){return hr(await Xi(t))}var gr=1,Ve=16,yr=12,br=1+Ve+yr+16,Ft=1+Ve+yr;async function qi(t,e){let n=await crypto.subtle.importKey("raw",je(t),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",hash:"SHA-256",salt:e,iterations:3e6},n,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function wr(t){return!(t instanceof Uint8Array)||t.length<br?!1:t[0]===gr}async function Yi(t,e){if(typeof e!="string"||!e)throw new TypeError("tryDecryptWithPassword: password required");if(!(t instanceof Uint8Array)||t.length<br)return{ok:!1,reason:"malformed"};if(t[0]!==gr)return{ok:!1,reason:"malformed"};let n=t.subarray(1,1+Ve),o=t.subarray(1+Ve,Ft),r=t.subarray(Ft),i=await qi(e,n),s;try{s=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:o,additionalData:t.subarray(0,Ft)},i,r))}catch{return{ok:!1,reason:"wrong-password"}}return{ok:!0,plaintext:s}}async function vr(t,e,n){if(!n||typeof n.malformedMsg!="string"||typeof n.wrongPasswordMsg!="string")throw new TypeError("decryptWithPasswordOrThrow: { malformedMsg, wrongPasswordMsg } strings required");let o=await Yi(t,e);if(o.ok)return o.plaintext;throw o.reason==="wrong-password"?new Error(n.wrongPasswordMsg):new Error(n.malformedMsg)}var Ge=wr;function _r(t,e){return vr(t,e,{malformedMsg:"malformed encrypted bundle",wrongPasswordMsg:"wrong password or corrupt bundle"})}var Ji=1,xr=1024,$r=1024,We=200,kr=100*1024*1024,Qi=Math.ceil(kr*4/3)+16,Er=512,Ar=64;function es(t){if(!t||typeof t!="object")return"payload is not an object";if(t.version!==Ji)return`unsupported export version: ${t.version}`;if(!t.workspace||typeof t.workspace!="object")return"workspace metadata missing";if(typeof t.workspace.id!="string")return"workspace.id must be a string";if(typeof t.workspace.name!="string")return"workspace.name must be a string";if(typeof t.workspace.privateKey!="string")return"workspace.privateKey must be a string";if(t.workspace.createdAt!==void 0&&!Number.isFinite(t.workspace.createdAt))return"workspace.createdAt must be a finite number or omitted";if(!Array.isArray(t.reports))return"reports field must be an array";if(t.reports.length>$r)return`reports count (${t.reports.length}) exceeds cap (${$r})`;if(t.bundles!==void 0){if(!Array.isArray(t.bundles))return"bundles field must be an array when present";if(t.bundles.length>xr)return`bundles count (${t.bundles.length}) exceeds cap (${xr})`;for(let e of t.bundles){if(typeof e!="string")return"bundles entries must be strings";if(e.length>We)return`bundle integrity exceeds per-entry length cap (${We})`}}if(t.bundleBlobs!==void 0){if(!Array.isArray(t.bundleBlobs))return"bundleBlobs field must be an array when present";if(t.bundleBlobs.length>Ar)return`bundleBlobs count (${t.bundleBlobs.length}) exceeds cap (${Ar})`;for(let e of t.bundleBlobs){if(!e||typeof e!="object"||Array.isArray(e))return"bundleBlobs entries must be objects";if(typeof e.integrity!="string"||e.integrity.length===0)return"bundleBlobs.integrity must be a non-empty string";if(e.integrity.length>We)return`bundleBlobs.integrity exceeds per-entry length cap (${We})`;if(typeof e.name!="string"||e.name.length===0)return"bundleBlobs.name must be a non-empty string";if(e.name.length>Er)return`bundleBlobs.name exceeds per-entry length cap (${Er})`;if(e.name.includes("\0"))return"bundleBlobs.name cannot contain NUL";if(typeof e.data!="string")return"bundleBlobs.data must be a base64 string";if(e.data.length>Qi)return`bundleBlobs.data exceeds per-blob size cap (${kr} bytes raw)`}}return null}async function Pt(t,e){if(Ge(t)){if(typeof e!="string"||!e)throw new TypeError("parseWorkspaceBundleBytes: password required for encrypted bundle");let o=await _r(t,e);try{return Ke(await Ut(o))}catch(r){throw new Error("wrong password or corrupt bundle",{cause:r})}}let n;try{n=await Ut(t)}catch(o){throw new Error(`gzip decompression failed: ${o.message}`,{cause:o})}return Ke(n)}function Ke(t){let e;try{e=JSON.parse(t)}catch(r){throw new Error(`payload is not JSON: ${r.message}`,{cause:r})}let n=es(e);if(n===null)return e;let o=n.includes("exceeds cap");throw new Error(o?n:`not a deepview workspace export: ${n}`)}var ts=/^\d+$/u;function ns(t){for(let e=0;e<t.length;e++){let n=t.codePointAt(e);if(n<32||n===127)return!0}return!1}var zt=512;function rs(t){return typeof t=="string"&&t.length>0&&t.length<=zt&&!ns(t)}function we(t){return rs(t)&&!ts.test(t)}var nl=Object.freeze({manage:"/manage","manage-bundles":"/manage/bundle","manage-scans":"/manage/scans","manage-reports":"/manage/report","manage-repos":"/manage/repositories","admin-users":"/manage/users","manage-teams":"/manage/team","manage-import":"/manage/import","manage-links":"/manage/links","manage-deduplication":"/manage/deduplication","manage-history":"/manage/history"});function os(t){if(typeof t=="string")return t.length>0?t:null;if(!t||typeof t!="object"||Array.isArray(t))return null;let{id:e}=t;return typeof e=="string"&&e.length>0?e:null}function Sr(t){let e;try{e=JSON.parse(t)}catch{return null}if(!Array.isArray(e)||e.length===0)return null;let n=[],o=0;for(let r of e){if(!Array.isArray(r))return null;let i=new Set;for(let s of r){let c=os(s);if(c===null)return null;we(c)?i.add(c):o++}i.size>1&&n.push([...i])}return{groups:n,skipped:o}}function G(t,e){let n=t.trimStart().startsWith("[")?Sr(t):null;if(n)return{data:{source:"links",findings:[],links:n.groups},format:"links",reason:null};let o=ze(t);if(o.data!=null||dr(t,e)!=="codex")return o;try{return{data:{type:"security",source:"codex-security",findings:Tt(t).flatMap(i=>i.data.findings)},format:"codex",reason:null}}catch(r){return{data:null,format:null,reason:r instanceof Error?r.message:"Invalid Codex CSV"}}}function Xe(t,e){let n=G(t,e);return n.data==null?Promise.resolve(null):He(JSON.stringify(n.data))}var is=["inprogress","fixed","invalid","deleted","ignored"];function ss(t){return typeof t=="string"&&is.includes(t)}function Ze(t){if(t===null)return null;if(typeof t!="object"||Array.isArray(t))return"invalid";let e=t,n={},o=e.color;if(o!=null){if(typeof o!="string"||o.length>50)return"invalid";o!==""&&(n.color=o)}let r=e.triage;if(r!=null){if(!ss(r))return"invalid";n.triage=r}for(let s of["comment","fix"]){let c=e[s];if(c!=null){if(typeof c!="string"||c.length>1e4)return"invalid";c!==""&&(n[s]=c)}}let i=e.flagged;if(i!=null){if(typeof i!="boolean")return"invalid";n.flagged=i}return n}async function Ir(t,{session:e,confirmImport:n,...o}){if(e?.role!=="admin"||!e.csrfToken)throw new Error("An administrator session is required.");if(t!=null&&(typeof t!="object"||Array.isArray(t)))throw new Error("Invalid local triage.");let r=Object.create(null);for(let[d,p]of Object.entries(t??{})){let{ignoredReports:u,scopedIgnoredReports:f,...m}=N(p)??{};Object.keys(m).length!==0&&(r[d]=m)}let i=Object.keys(r).length,s=new Set,c=[],a;if(i>0)do{o.signal?.throwIfAborted();let d="/api/admin/reports/finding-ids"+(a?`?after=${encodeURIComponent(a)}`:""),{reports:p,nextCursor:u}=await o.api.send(d);o.signal?.throwIfAborted();for(let f of p){let m=f.findingIds.filter(h=>Object.hasOwn(r,h)&&!s.has(h));m.length>0&&c.push({id:f.id,ids:m});for(let h of m)s.add(h)}a=u}while(a);for(let d of s){if(!d||d.length>100)throw new Error(`Triage finding IDs must be between 1 and ${100} characters.`);if(Ze(r[d])==="invalid")throw new Error(`Triage for ${d} exceeds the managed server limits.`)}if(o.signal?.throwIfAborted(),n){let d=await n({matched:s.size,available:i});if(o.signal?.throwIfAborted(),!d)return null}let l=o.importedIds??new Set;for(let d of c)await Ht(r,{...o,importedIds:l,ids:d.ids,path:`/api/admin/reports/${encodeURIComponent(d.id)}/import-triage`});return s.size}function cs(t,e){let n=[],o=Object.create(null);for(let[r,i]of Object.entries(t)){let s=e[r];if(!s)throw new Error("The server did not return the requested triage snapshot.");let c=s.entry??{},a=o[r]={...c};delete a.comment;for(let[l,d]of Object.entries(i))if(l==="comment"){if(s.comments.some(p=>p.body===d))continue;s.comments.length>0?n.push({id:r,property:l,local:s.comments.map(p=>p.body).join(`
|
|
60
|
+
|
|
61
|
+
`),imported:d}):a.comment=d}else if(c[l]!==void 0&&c[l]!==d){let p=u=>l==="flagged"?u?"flagged":"not flagged":u;n.push({id:r,property:l,local:p(c[l]),imported:p(d)})}else a[l]=d}return{entries:o,conflicts:n}}async function ls(t,e,n,o,r){r?.throwIfAborted();let{entries:i,conflicts:s}=cs(t,e);if(s.length===0)return i;let c=await o(s,n,{title:"Triage conflicts on import",intro:"disagree with stored triage on",trailingNote:"Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.",importedSideLabel:"Apply imported"});if(r?.throwIfAborted(),!c)throw new Error("Triage conflict resolution was cancelled.");for(let a of s){let l=c[`${a.id}:${a.property}`];if(!["local","imported"].includes(l))throw new Error("Resolve every triage conflict before importing.");l==="imported"&&(i[a.id][a.property]=t[a.id][a.property])}return i}function ds(t,e){let n=[],o={entries:{},expected:{}};for(let[r,i]of Object.entries(t)){let s={entries:{...o.entries,[r]:i},expected:{...o.expected,[r]:e[r].version}};if(new TextEncoder().encode(JSON.stringify(s)).length<=262144){o=s;continue}if(Object.keys(o.entries).length===0)throw new Error("This triage entry is too large to import.");n.push(o),o={entries:{[r]:i},expected:{[r]:e[r].version}}}return Object.keys(o.entries).length>0&&n.push(o),n}async function Ht(t,{api:e,path:n,ids:o=Object.keys(t),importedIds:r=new Set,lookup:i=new Map,resolveConflicts:s,signal:c}){o=o.filter(a=>Object.hasOwn(t,a)&&!r.has(a));for(let a=0;a<o.length;a+=200){let l=o.slice(a,a+200);for(let d=0;d<5&&l.length>0;d++){c?.throwIfAborted();let{snapshots:p}=await e.send(n,{findingIds:l}),u=Object.fromEntries(l.map(m=>[m,t[m]])),f=await ls(u,p,i,s,c);for(let m of ds(f,p)){if(c?.throwIfAborted(),(await e.send(n,m)).conflict)break;Object.keys(m.entries).forEach(h=>r.add(h))}l=l.filter(m=>!r.has(m))}if(l.length>0)throw new Error("Stored triage keeps changing. Retry to resolve it against the latest values.")}}function Rr(t){if(typeof t!="string")return{ok:!0,path:null};if(/\p{Cc}/u.test(t)||t.includes("\\")||t!==t.trim())return{ok:!1};let e=[];for(let o of t.split("/"))if(!(o===""||o===".")){if(o===".."||o!==o.trim())return{ok:!1};e.push(o)}let n=e.join("/");return n.length>500?{ok:!1}:{ok:!0,path:n===""?null:n}}function jt(t,e){return!t||e===t||e.startsWith(`${t}/`)}function us(t,e){if(jt(t.oldPath,e)){let o=e.slice(t.oldPath.length).replace(/^\//u,"");return{directory:[t.newPath,o].filter(Boolean).join("/"),filePrefix:""}}if(!jt(e,t.oldPath))return null;let n=t.oldPath.slice(e.length).replace(/^\//u,"");return t.newPath===n?{directory:"",filePrefix:n}:t.newPath.endsWith(`/${n}`)?{directory:t.newPath.slice(0,-n.length-1),filePrefix:n}:null}function Cr(t,e,n,o=""){let r=null,i=-1;for(let s of n){if(s.oldRepo.toLowerCase()!==t.toLowerCase())continue;let c=us(s,e);!c||!jt(c.filePrefix,o)||s.oldPath.length<=i||(r={repoId:s.repoId,directory:c.directory},i=s.oldPath.length)}return r}async function Tr(t,e){let n=new Uint8Array(await t.arrayBuffer());return Ge(n)?e({tryPassword:o=>Pt(n,o)}):n[0]===31&&n[1]===139?Pt(n):Ke(new TextDecoder("utf-8",{fatal:!0}).decode(n))}function Lr(t,e,n,o){let r=t?Cr(t,e,o):null,i=n.find(s=>r?s.repoId===r.repoId:s.fullName.toLowerCase()===t?.toLowerCase());return{repoId:i?.repoId??null,directory:r?.directory??e,github:i?.fullName??t}}async function Mr(t,e,n=[]){let o=new Map,r=[];for(let a of t.reports){if(typeof a?.name!="string"||!a.name||typeof a.content!="string")throw new Error("Every report must have a name and content.");let l=G(a.content,a.name);if(!l.data)throw new Error(`${a.name}: ${l.reason??"Unsupported report"}`);let d=me(l.data),p=d??me(a)??me({repo:{github:t.repoUrls?.[a.name]}}),u=Rr(l.data.repo?.directory);if(!u.ok)throw new Error(`${a.name}: invalid repository directory`);let f=l.format==="links"?[]:(await Xe(a.content,a.name))?.findings??[];for(let h of f)h.id&&o.set(h.id,h);let m=u.path??"";r.push({...a,links:l.format==="links",...Lr(p,m,e,d?n:[]),declaredDirectory:m,embedded:d,ids:[...new Set(f.map(h=>h.id).filter(Boolean))],uploaded:null})}let i=Object.create(null);if(t.triage!=null&&(typeof t.triage!="object"||Array.isArray(t.triage)))throw new Error("Invalid workspace triage.");let s=await mr(t.triage,a=>t.reports.find(l=>l.name===a)?.content);for(let[a,l]of Object.entries(s.entries)){if(!o.has(a))continue;let d=N(l);if(!d)continue;let{ignoredReports:p,scopedIgnoredReports:u,...f}=d;Object.keys(f).length!==0&&(i[a]=f)}let c=[];for(let a of t.bundleBlobs??[]){let l=Uint8Array.fromBase64(a.data),d=`sha512-${new Uint8Array(await crypto.subtle.digest("SHA-512",l)).toBase64()}`;if(d!==a.integrity)throw new Error(`${a.name}: bundle integrity mismatch`);c.push({name:a.name,integrity:d,bytes:l,uploaded:null})}return{name:t.workspace.name.slice(0,100),reports:r,bundles:c,triage:i,lookup:o,references:t.bundles??[],team:null,completed:new Set,importedIds:new Set}}function ee(t,e,n){async function o(r,i,s={}){n?.throwIfAborted();let c=await t(r,{credentials:"same-origin",signal:n,...i===void 0?{}:{method:"POST",body:i instanceof File?i:JSON.stringify(i)},headers:{...i instanceof File?{}:{"content-type":"application/json"},"x-csrf-token":e.csrfToken,...s}});if(n?.throwIfAborted(),c.status===409)return{conflict:!0};if(!c.ok)throw new Error(`Import request failed (HTTP ${c.status}). You can retry the remaining steps.`);let a=await c.json();return n?.throwIfAborted(),a}return{send:o}}async function ps(t,e,n,o,r,i){if(t.bundles.length===0&&t.references.length===0)return;let s=r??(await n.send("/api/admin/bundles")).bundles,c=new Set(t.bundles.map(l=>l.uploaded.id));if([...c].some(l=>!s.some(d=>d.id===l)))throw new Error("Could not verify the uploaded source bundles. Retry the import.");let a=new Set(t.references);for(let l of s){if(!c.has(l.id)&&!a.has(l.integrity))continue;let d=!i.has(l.repoId),p=d?e:l.repoId;d&&await o(`bundle-repo:${l.id}:${p}`,()=>n.send("/api/admin/bundles/set-repo",{bundleId:l.id,repoId:p}));let u=d?"":l.repoDirectory??"";await o(`repo:${p}:${u}`,()=>n.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:p,path:u}))}}async function fs(t,e){t.uploaded||(t.uploaded=await e.send("/api/admin/deduplication",new File([t.content],t.name),{"x-report-filename":encodeURIComponent(t.name)}))}async function ms(t,e){let n=(await e.send("/api/admin/repositories/browsable")).repos,o=t.reports.filter(r=>!r.links&&r.embedded&&!r.uploaded);if(o.length>0){let{aliases:r=[]}=await e.send("/api/admin/repositories/aliases");for(let i of o)Object.assign(i,Lr(i.embedded,i.declaredDirectory,n,r))}return new Set(n.map(r=>r.repoId))}async function Or(t,{api:e,session:n,defaultRepo:o,includeTriage:r,resolveConflicts:i,signal:s,progress:c=()=>{}}){if(n?.role!=="admin"||!n.csrfToken)throw new Error("An administrator session is required.");if(!t.name.trim()||t.name.trim().length>100)throw new Error("Enter a team name of up to 100 characters.");if(r)for(let[u,f]of Object.entries(t.triage)){if(!u||u.length>100)throw new Error(`Triage finding IDs must be between 1 and ${100} characters. Choose Skip triage to import the files without it.`);if(Ze(f)==="invalid")throw new Error(`Triage for ${u} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}s?.throwIfAborted();let a=null;if(t.bundles.length===0){let u=new Set(t.references);a=u.size>0?(await e.send("/api/admin/bundles")).bundles.filter(f=>u.has(f.integrity)):[]}if(t.reports.length===0&&t.bundles.length===0&&a.length===0)throw new Error(t.references.length>0?"None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.":"This workspace contains no report or bundle files.");let l=await ms(t,e);for(let u of t.reports.filter(f=>!f.links)){if(u.embedded&&!l.has(u.repoId))throw new Error(`Connect ${u.embedded} in Repositories before importing ${u.name}.`);if(!l.has(u.repoId)&&!l.has(o))throw new Error(`Choose an active repository for ${u.name}.`)}if((t.bundles.length>0||a.some(u=>!l.has(u.repoId)))&&!l.has(o))throw new Error("Choose an active repository for the source bundles.");let d=()=>s?.throwIfAborted(),p=async(u,f)=>{d(),t.completed.has(u)||(await f(),t.completed.add(u))};if(d(),!t.team){let u=await e.send("/api/admin/teams",{name:t.name.trim()});if(u.conflict)throw new Error("A team already has this name. Choose another name.");t.team=u}await p("member",()=>e.send("/api/admin/teams/set-member",{teamId:t.team.id,userId:n.id,security:!0,dependencies:!0}));for(let u of t.bundles)d(),c(`Importing ${u.name}\u2026`),u.uploaded||(u.uploaded=await e.send("/api/admin/bundles",new File([u.bytes],u.name),{"x-bundle-filename":encodeURIComponent(u.name)}));await ps(t,o,e,p,a,l);for(let u of t.reports){if(d(),c(`Importing ${u.name}\u2026`),u.links){await fs(u,e);continue}let f=l.has(u.repoId)?u.repoId:o;if(!u.uploaded){let g=await e.send("/api/admin/reports",new File([u.content],u.name),{"x-report-filename":encodeURIComponent(u.name),"x-repo-id":String(f),"x-repo-directory":encodeURIComponent(u.directory)});if(g.conflict)throw new Error(`Could not reuse the stored report ${u.name}. Retry the import.`);u.uploaded=g}let m=u.uploaded;l.has(m.repoId)||await p(`report-repo:${m.id}:${f}:${u.directory}`,async()=>{if((await e.send("/api/admin/reports/set-repo",{reportId:m.id,repoId:f,directory:u.directory})).conflict)throw new Error(`Could not assign the stored report ${u.name} to its repository.`);m.repoId=f,m.repoDirectory=u.directory});let h=m.repoDirectory??"";await p(`repo:${m.repoId}:${h}`,()=>e.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:m.repoId,path:h})),r&&await Ht(t.triage,{api:e,resolveConflicts:i,signal:s,ids:u.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(u.uploaded.id)}/import-triage`}),await p(`publish:${u.uploaded.id}`,()=>e.send("/api/admin/reports/set-visible",{reportId:u.uploaded.id,visible:!0}))}return t.team}function Vt(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();return{get locked(){return e()},unlock:n=>t.unlockEncryption(n),async read({signal:n}={}){let o=!1,r=t.onVaultStateChange(()=>{o=!0}),i=()=>{if(n?.throwIfAborted(),e()||o)throw new Error("Local data was locked or changed. Unlock it and import triage again.")};try{i();let s=await t.readTriageBlob();return i(),s}finally{r()}}}}function qe(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();async function n(){let r=JSON.parse(await t.hydrateKey("deepview.workspaces")||"[]");return(Array.isArray(r)?r:r.workspaces??[]).filter(i=>typeof i.id=="string"&&typeof i.name=="string")}async function o(r,i){let s=!1,c=[t.onVaultStateChange,t.onFileMutated,t.onBundleMutated].map(l=>l(()=>{s=!0})),a=()=>{if(i?.throwIfAborted(),e()||s)throw new Error("Local data was locked or changed. Unlock it and select the workspace again.")};try{a();let l=await r(a);return a(),l}finally{c.forEach(l=>l())}}return{get locked(){return e()},unlock:r=>t.unlockEncryption(r),list:({signal:r}={})=>o(async()=>(await n()).map(i=>({id:i.id,name:i.name})),r),read:(r,{signal:i}={})=>o(async s=>{let c=(await n()).find(m=>m.id===r);if(!c)throw new Error("This local workspace no longer exists.");let a=JSON.stringify(c),l=JSON.parse(await t.hydrateKey("deepview.repoUrls")||"{}"),d=[];for(let m of c.reports??[]){s();let h=await t.withStoredItem("report",m,()=>t.readFile(m));s(),d.push({name:m,content:h,...l[m]?{repo:{github:l[m]}}:{}})}let p=await t.listBundles(),u=[];for(let m of c.bundles??[]){s();let h=p.find(y=>y.integrity===m);if(!h)continue;let g=await t.withStoredItem("bundle",m,()=>t.readBundle(m));s(),u.push({integrity:m,name:h.name,data:g.toBase64()})}let f=await t.readTriageBlob()??{};if(JSON.stringify((await n()).find(m=>m.id===r))!==a)throw new Error("The local workspace changed. Select it again.");return{version:1,workspace:{id:r,name:c.name,privateKey:""},reports:d,bundles:c.bundles??[],bundleBlobs:u,triage:f,repoUrls:l}},i)}}async function Nr(t){let e=await crypto.subtle.digest("SHA-512",t);return`sha512-${new Uint8Array(e).toBase64()}`}var te=t=>t==="bundle"?"bundles":"reports",Br=(t,e)=>JSON.stringify([t,e||""]),Dr=(t,e)=>new Set(e.map(n=>t==="bundle"?n.integrity:Br(n.sha256,n.analyzer)));async function Ur(t){let e=new Uint8Array(await t.arrayBuffer()),n=G(new TextDecoder().decode(e),t.name);if(!n.data)throw new Error(n.reason??"Not a recognized report");let o=new Uint8Array(await crypto.subtle.digest("SHA-256",e)).toBase64({alphabet:"base64url",omitPadding:!0});return{hash:o,key:Br(o,typeof n.data.source=="string"?n.data.source:null)}}async function Fr(t,{source:e,deps:n,api:o,signal:r}){let i=JSON.parse(await n.hydrateKey("deepview.workspaces")||"[]"),s=(Array.isArray(i)?i:i.workspaces??[]).filter(u=>typeof u.id=="string"&&typeof u.name=="string");r.throwIfAborted();let c=await e.list(t),a=Dr(t,(await o.send(`/api/admin/${te(t)}`))[te(t)]),l=s.map(u=>({id:u.id,name:u.name,items:[]})),d={id:null,name:"Not in a workspace",items:[]},p=[];for(let u of c){r.throwIfAborted();let f={value:u.value,name:u.label,key:u.value,synced:!1,present:!1,error:""};if(t==="report")try{Object.assign(f,await e.importItem(t,f.value,Ur,{signal:r})),f.syncHash=await n.reportSyncHash(f.value)}catch(h){r.throwIfAborted(),f.error=String(h?.message??h)}r.throwIfAborted(),f.present=a.has(f.key);let m=!1;s.forEach((h,g)=>{if(!h[te(t)]?.includes(f.value))return;let y=n.localContentSyncStatus(h.id,t,f.value,f.syncHash);f.synced||=y.synced,l[g].items.push({item:f,...y}),m=!0}),m||d.items.push({item:f,synced:!1,cached:!1}),p.push(f)}return{kind:t,items:p,groups:[...l,d].filter(u=>u.items.length>0)}}async function Pr(t,e,{source:n,api:o,signal:r,progress:i=()=>{},imported:s=new Set}){let{kind:c}=t,a=Dr(c,(await o.send(`/api/admin/${te(c)}`))[te(c)]),l=new Set(e);for(let d of t.items)if(r.throwIfAborted(),!(!l.has(d.value)||d.error||d.present)){if(a.has(d.key)){d.present=!0;continue}i(`Importing ${d.name}\u2026`),await n.importItem(c,d.value,async p=>{let u=c==="report"?(await Ur(p)).key:await Nr(new Uint8Array(await p.arrayBuffer()));if(r.throwIfAborted(),u!==d.key)throw new Error(`${d.name} changed. Choose files again before importing.`);if((await o.send(`/api/admin/${te(c)}`,p,{[`x-${c}-filename`]:encodeURIComponent(p.name)})).conflict)throw new Error(`Could not import ${d.name}. Try again.`)},{signal:r}),a.add(d.key),d.present=!0,s.add(d.value)}return s.size}var hs=(t,e)=>t===void 0?"managed-only":e===void 0?"local-only":"mismatch";function gs(t,e){let n=e.slice(),o=t.map(s=>{let c=n.indexOf(s);return c!==-1&&n.splice(c,1),{text:s,different:c===-1}}),r=t.slice(),i=e.map(s=>{let c=r.indexOf(s);return c!==-1&&r.splice(c,1),{text:s,different:c===-1}});return!o.some(s=>s.different)&&!i.some(s=>s.different)?null:{property:"comment",local:o,managed:i,kind:o.some(s=>s.different)?i.some(s=>s.different)?"mismatch":"local-only":"managed-only"}}function ys(t,e){let n=N(t)??{},o=N(e.entry)??{},r=[];for(let s of["triage","color","fix","flagged"])n[s]!==o[s]&&r.push({property:s,local:n[s],managed:o[s],kind:hs(n[s],o[s])});let i=gs(n.comment?[n.comment]:[],e.comments.map(s=>s.body));return i&&r.push(i),n.ignoredReports?.length&&r.push({property:"ignoredReports",local:[...new Set(n.ignoredReports)],managed:void 0,kind:"local-only"}),r}async function bs(t,{lookup:e,triage:n,matched:o,findings:r,api:i,signal:s}){let c=[...new Set(t.findingIds)].filter(a=>e.has(a)&&!o.has(a));for(let a=0;a<c.length;a+=200){let l=c.slice(a,a+200);if(l.some(p=>p.length>100))throw new Error("A shared finding ID exceeds the managed triage limit.");s.throwIfAborted();let{snapshots:d}=await i.send(`/api/admin/reports/${encodeURIComponent(t.id)}/import-triage`,{findingIds:l});s.throwIfAborted();for(let p of l){if(!d?.[p])throw new Error("The server did not return the requested triage snapshot.");let u=ys(n[p],d[p]);u.length>0&&r.push({id:p,finding:e.get(p),differences:u}),o.add(p)}}}async function zr({source:t,readTriage:e,api:n,signal:o,progress:r=()=>{}}){let i=new Map,s=[];for(let p of await t.list("report")){o.throwIfAborted(),r(`Reading ${p.label}\u2026`);try{let u=await t.importItem("report",p.value,async f=>{let m=await f.text(),h=G(m,f.name);if(!h.data)throw new Error(h.reason??"Not a recognized report");return h.format==="links"?[]:(await Xe(m,f.name))?.findings??[]},{signal:o});o.throwIfAborted();for(let f of u)typeof f.id!="string"||!f.id||(i.has(f.id)||i.set(f.id,{...f,reports:[]}),i.get(f.id).reports.push(p.label))}catch(u){o.throwIfAborted(),s.push({name:p.label,reason:String(u?.message??u)})}}let c=await e()??{};if(o.throwIfAborted(),typeof c!="object"||Array.isArray(c))throw new Error("Invalid local triage.");let a=[],l=new Set;if(i.size===0)return{matched:0,localFindings:0,findings:a,skipped:s};let d;do{o.throwIfAborted(),r("Comparing local and managed triage\u2026");let p=await n.send("/api/admin/reports/finding-ids"+(d?`?after=${encodeURIComponent(d)}`:""));o.throwIfAborted();for(let u of p.reports)await bs(u,{lookup:i,triage:c,matched:l,findings:a,api:n,signal:o});d=p.nextCursor}while(d);return o.throwIfAborted(),{matched:l.size,localFindings:i.size,findings:a,skipped:s}}function ws(t,e){if(customElements.get("managed-admin-import"))return;class n extends t{static styles=[ne(mn),ne(hn)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error="",this._message="",this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId="",this._triage="",this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),this._drag=!0)},this._drop=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),r.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...r.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId="",!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage||this._importingContent||this._comparingTriage)&&(this._operation?.abort(),this._message="",this._error=this._comparingTriage?"Local data changed or was locked. Compare triage again to continue.":this._importingContent?"Local data changed or was locked. Choose files again to continue.":this._importingTriage?"Local data changed or was locked. Import triage again to continue.":"Local data changed or was locked. Choose the workspace again."))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener("dragover",this._over),this.addEventListener("drop",this._drop),globalThis.addEventListener("blur",this._blur),globalThis.addEventListener("storage",this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener("dragover",this._over),this.removeEventListener("drop",this._drop),globalThis.removeEventListener("blur",this._blur),globalThis.removeEventListener("storage",this._localChanged),super.disconnectedCallback()}updated(r){r.has("session")&&(this._role!=="admin"||r.get("session")?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(r){if(this._busy||this._role!=="admin")return;let i=this._operation=new AbortController,s=AbortSignal.any([i.signal,this.appState.sessionController.signal]);this._busy=!0,this._error="";try{await r(s),s.throwIfAborted()}catch(c){s.aborted||(this._error=String(c?.message??c))}finally{this._operation===i&&(this._busy=!1)}}async _loadCatalog(){if(this._role==="admin")try{await this._loadCollection("workspace-import:catalog","import options",async r=>{let i=ee(e,this.session,r),[s,c,a,l]=await Promise.all([i.send("/api/admin/reports"),i.send("/api/admin/teams"),i.send("/api/admin/bundles"),i.send("/api/admin/repositories/aliases")]);return{repos:s.repos,teams:c.teams,bundles:a.bundles,aliases:l.aliases}},r=>{this._catalog=r})}catch(r){this._error=String(r?.message??r)}}_browse(){let r=document.createElement("input");r.type="file",r.multiple=!0,r.accept=".enc,.gz,.json",r.addEventListener("change",()=>{this._files.push(...r.files),this._nextFile()},{once:!0}),r.click()}async _prepare(r,i){if(!r)return;if(this._catalog||await this._loadCatalog(),i.throwIfAborted(),!this._catalog)throw new Error("Could not load repositories. Try again.");let s=await Mr(r,this._catalog.repos,this._catalog.aliases);i.throwIfAborted();let c=new Set(this._catalog.teams.map(p=>p.name)),a=s.name||"Imported workspace",l=2;for(;c.has(s.name);){let p=` (${l++})`;s.name=a.slice(0,100-p.length)+p}let d=new Set(s.reports.map(p=>p.repoId).filter(p=>p!=null));this._repo=d.size===1?[...d][0]:null,this._triage=Object.keys(s.triage).length>0?"":"skip",this._plan=s,this._message=""}async _nextFile(){if(this._files.length===0||this._busy)return;let r=this._files.shift();this._local=!1,this._plan=null,await this._action(async i=>{let s=await Tr(r,this.promptPassword);i.throwIfAborted(),await this._prepare(s,i)})}async _unlock(r,i){this._unlocking=!0;try{return!r.locked||await r.unlock({signal:i})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async r=>{let i=qe(this.localDeps);await this._unlock(i,r)&&(r.throwIfAborted(),this._workspaces=await i.list({signal:r}))})}async _readLocal(){if(!this._localId)return;let r=this._localId;this._local=!0,this._plan=null,await this._action(async i=>{let s=qe(this.localDeps);if(await this._unlock(s,i)){this._readingLocal=!0;try{await this._prepare(await s.read(r,{signal:i}),i)}finally{this._readingLocal=!1}}})}async _import(){!this._plan||!this._triage||!this._csrf||(await this._action(async r=>{if(this._local&&qe(this.localDeps).locked)throw new Error("Unlock local data and choose the workspace again.");let i=this._plan,s=["teams","reports","bundles","history","workspace-import","scan-sources","repo-impact"];try{let c=await this.appState.mutate(()=>Or(i,{api:ee(e,this.session,r),session:this.session,defaultRepo:this._repo,includeTriage:this._triage==="include",resolveConflicts:this.resolveConflicts,signal:r,progress:a=>{this._message=a}}),s);this._catalog.teams.push(c),this._message=`Imported into ${c.name}.`,this._plan=null}finally{this.appState.invalidate(s),i.team&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async r=>{this._importingTriage=!0,this._message="";let i=new Set,s=["reports","history"];try{let c=Vt(this.localDeps);if(!await this._unlock(c,r))return;this._readingLocal=!0;let a;try{a=await c.read({signal:r})}finally{this._readingLocal=!1}let l=await Ir(a,{api:ee(e,this.session,r),session:this.session,resolveConflicts:this.resolveConflicts,signal:r,importedIds:i,confirmImport:async d=>(await this.confirmTriageImport({...d,signal:r}))?.confirmed===!0});if(r.throwIfAborted(),l===null)return;this._message=l?`Imported triage for ${l} finding${l===1?"":"s"}.`:"No local triage matches findings in managed reports."}finally{this._importingTriage=!1,this.appState.invalidate(s),i.size>0&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}})}async _compareLocalTriage(){this._csrf&&await this._action(async r=>{this._comparingTriage=!0,this._message="";let i=this.localImportSource,s=i.subscribe(this._localChanged);try{if(!await this._unlock(i,r))return;r.throwIfAborted(),this._readingLocal=!0;let c=Vt(this.localDeps),a=await zr({source:i,signal:r,readTriage:()=>c.read({signal:r}),api:ee(e,this.session,r),progress:l=>{this._message=l}});r.throwIfAborted(),this._message="",await this.showTriageComparison({comparison:a,signal:r})}finally{s(),this._readingLocal=!1,this._comparingTriage=!1,this._message=""}})}async _importLocalContent(r){this._csrf&&await this._action(async i=>{this._importingContent=!0,this._message="";let s=this.localImportSource,c=["reports","bundles","bundle-metadata","history","workspace-import","scan-sources","repo-impact"],a=new Set,l=s.subscribe(this._localChanged);try{if(!await this._unlock(s,i))return;i.throwIfAborted(),this._readingLocal=!0;let d=ee(e,this.session,i),p=await Fr(r,{source:s,deps:this.localDeps,api:d,signal:i}),u=await this.confirmContentImport({plan:p,signal:i});if(i.throwIfAborted(),!u?.confirmed)return;let f=await Pr(p,u.selected,{source:s,api:d,signal:i,imported:a,progress:m=>{this._message=m}});this._message=`Imported ${f} ${r}${f===1?"":"s"}.`}finally{l(),this._readingLocal=!1,this._importingContent=!1,this.appState.invalidate(c),a.size>0&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}})}render(){if(this._role!=="admin")return b;let r=this._plan,i=r?Object.keys(r.triage).length:0,s=new Set([...r?.references??[],...r?.bundles.map(l=>l.integrity)??[]]),c=(this._catalog?.bundles??[]).filter(l=>s.has(l.integrity)),a=r?.references.filter(l=>!r.bundles.some(d=>d.integrity===l)).length??0;return x`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${fn("manage-import",this._role,this.allowShare)}<h1>Import</h1><section class="triage-import" aria-label="Import local files"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent("bundle")}">Import bundles</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent("report")}">Import reports</button></div><p>Choose files from this browser, grouped by workspace. Import files without teams or triage.</p></section><section class="triage-import" aria-label="Local triage"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._compareLocalTriage()}">Compare triage</button></div><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?"dragging":""}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?x`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${l=>{this._localId=l.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(l=>x`<option value="${l.id}">${l.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?x`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:b}</section>`:b} ${r?x`<section class="import-preview" aria-label="Import options">${r.team?x`<p>Team ${r.team.name} has been created. Retry continues its remaining import steps.</p>`:b} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${r.name}" ?disabled="${this._busy||!!r.team}" @input="${l=>{r.name=l.target.value,this.requestUpdate()}}"><p>${r.reports.length} reports / links · ${s.size} source bundles · ${i} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??"")}" ?disabled="${this._busy||!!r.team}" @change="${l=>{this._repo=l.target.value?Number(l.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(l=>x`<option value="${String(l.repoId)}" ?selected="${this._repo===l.repoId}">${l.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${r.reports.map(l=>x`<li>${l.name}<span>${l.links?"Global deduplication \u2014 enabled for all teams":l.github??"Uses selected repository"}${l.embedded&&l.repoId==null?" \u2014 connect this repository first":""}</span></li>`)}</ul>${c.length>0?x`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${c.map(l=>x`<li>${l.filename}<span>${l.repoFullName?`${l.repoFullName}${l.repoDirectory?`/${l.repoDirectory}`:""}`:"Uses selected repository"}</span></li>`)}</ul>`:b} ${a?x`<p>${a} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:b} ${i?x`<fieldset ?disabled="${this._busy||!!r.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage==="include"}" @change="${()=>{this._triage="include"}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage==="skip"}" @change="${()=>{this._triage="skip"}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:b} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?"Importing\u2026":r.team?"Retry remaining import":"Import workspace"}</button></section>`:b} ${this._message?x`<p role="status">${this._message}</p>`:b} ${this._error?x`<p class="error" role="alert">${this._error}${this._catalog?b:x`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:b} ${this._files.length>0&&!this._busy?x`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:b}</div>`}}customElements.define("managed-admin-import",n)}export{ws as registerWorkspaceImport};
|
|
57
62
|
/*! Bundled license information:
|
|
58
63
|
|
|
59
64
|
@lit/reactive-element/css-tag.js:
|