@zivis/mcp 0.1.8 → 0.1.10
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/LICENSE +201 -0
- package/README.md +19 -0
- package/dist/api-client.d.ts +2 -24
- package/dist/api-client.js +32 -52
- package/dist/auth/index.d.ts +1 -22
- package/dist/auth/index.js +17 -38
- package/dist/auth/jwt.d.ts +0 -16
- package/dist/auth/jwt.js +0 -13
- package/dist/auth/keychain.d.ts +6 -32
- package/dist/auth/keychain.js +83 -114
- package/dist/auth/oauth.d.ts +3 -32
- package/dist/auth/oauth.js +67 -61
- package/dist/auth/sessions.d.ts +5 -25
- package/dist/auth/sessions.js +20 -39
- package/dist/auth/token-refresh.d.ts +2 -22
- package/dist/auth/token-refresh.js +33 -36
- package/dist/cli.d.ts +1 -18
- package/dist/cli.js +30 -908
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -7
- package/dist/lib/inspect-cache.d.ts +10 -0
- package/dist/lib/inspect-cache.js +75 -0
- package/dist/lib/next-steps.d.ts +27 -0
- package/dist/lib/next-steps.js +21 -0
- package/dist/matcher/ast-eval.d.ts +8 -0
- package/dist/matcher/ast-eval.js +95 -0
- package/dist/matcher/finding.d.ts +55 -0
- package/dist/matcher/finding.js +1 -0
- package/dist/matcher/index.d.ts +8 -0
- package/dist/matcher/index.js +202 -0
- package/dist/matcher/inference-candidates.d.ts +26 -0
- package/dist/matcher/inference-candidates.js +81 -0
- package/dist/matcher/walker.d.ts +7 -0
- package/dist/matcher/walker.js +71 -0
- package/dist/pattern-pack/index.d.ts +125 -0
- package/dist/pattern-pack/index.js +189 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/agents/privilege-separation.yaml +224 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/prompting/self-consistency-no-isolation.yaml +237 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/retrieval/context-injection-no-validator.yaml +348 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/security/late-org-filter.yaml +266 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/external_validator_on_facts.yaml +37 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/fact_validator_present.yaml +68 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/human_approval_gate.yaml +44 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/langgraph_state_machine_with_per_node_tools.yaml +35 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/per_sample_retrieval_diversification.yaml +38 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/prisma_extension_or_middleware_attaching_org_filter.yaml +31 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/row_level_security_policy.yaml +37 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/source_attribution_present.yaml +58 -0
- package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +167 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/agents/privilege-separation/identify.md +54 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/prompting/self-consistency-no-isolation/identify.md +60 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/retrieval/context-injection-no-validator/identify.md +109 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/security/late-org-filter/identify.md +78 -0
- package/dist/project-binding.d.ts +2 -19
- package/dist/project-binding.js +38 -21
- package/dist/prompts/audit-dependencies.d.ts +2 -0
- package/dist/prompts/audit-dependencies.js +47 -0
- package/dist/prompts/getting-started.d.ts +2 -0
- package/dist/prompts/getting-started.js +37 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.js +6 -0
- package/dist/resolve-application-id.d.ts +0 -4
- package/dist/resolve-application-id.js +0 -5
- package/dist/sanitize.d.ts +1 -21
- package/dist/sanitize.js +7 -41
- package/dist/server.d.ts +1 -13
- package/dist/server.js +142 -265
- package/dist/tools/artifacts.d.ts +76 -0
- package/dist/tools/artifacts.js +178 -0
- package/dist/tools/check-project.d.ts +5 -18
- package/dist/tools/check-project.js +122 -110
- package/dist/tools/check-repo-trust.d.ts +4 -19
- package/dist/tools/check-repo-trust.js +56 -47
- package/dist/tools/create-diagram.d.ts +0 -5
- package/dist/tools/create-diagram.js +0 -10
- package/dist/tools/create-document.d.ts +0 -5
- package/dist/tools/create-document.js +3 -9
- package/dist/tools/create-finding.d.ts +85 -0
- package/dist/tools/create-finding.js +136 -0
- package/dist/tools/delete-finding.d.ts +19 -0
- package/dist/tools/delete-finding.js +36 -0
- package/dist/tools/devx-run.d.ts +88 -0
- package/dist/tools/devx-run.js +175 -0
- package/dist/tools/discover-local-infra.d.ts +0 -10
- package/dist/tools/discover-local-infra.js +3 -73
- package/dist/tools/enterprise/get-org-zat.d.ts +0 -5
- package/dist/tools/enterprise/get-org-zat.js +0 -6
- package/dist/tools/explain-signal-for-diff.d.ts +34 -0
- package/dist/tools/explain-signal-for-diff.js +75 -0
- package/dist/tools/generate-diagram.d.ts +0 -6
- package/dist/tools/generate-diagram.js +21 -13
- package/dist/tools/get-application-overview.d.ts +0 -5
- package/dist/tools/get-application-overview.js +0 -6
- package/dist/tools/get-application.d.ts +0 -5
- package/dist/tools/get-application.js +0 -6
- package/dist/tools/get-diagram.d.ts +0 -5
- package/dist/tools/get-diagram.js +1 -11
- package/dist/tools/get-document.d.ts +0 -5
- package/dist/tools/get-document.js +0 -6
- package/dist/tools/get-oss-zat.d.ts +0 -5
- package/dist/tools/get-oss-zat.js +0 -7
- package/dist/tools/get-signal.d.ts +24 -0
- package/dist/tools/get-signal.js +75 -0
- package/dist/tools/get-started.d.ts +18 -0
- package/dist/tools/get-started.js +470 -0
- package/dist/tools/get-trust-keys.d.ts +0 -5
- package/dist/tools/get-trust-keys.js +0 -6
- package/dist/tools/import-openapi-endpoints.d.ts +0 -5
- package/dist/tools/import-openapi-endpoints.js +0 -6
- package/dist/tools/inspect-zat.d.ts +0 -5
- package/dist/tools/inspect-zat.js +0 -19
- package/dist/tools/inspect.d.ts +21 -0
- package/dist/tools/inspect.js +222 -0
- package/dist/tools/list-applications.d.ts +1 -6
- package/dist/tools/list-applications.js +0 -6
- package/dist/tools/list-diagrams.d.ts +0 -5
- package/dist/tools/list-diagrams.js +0 -6
- package/dist/tools/list-documents.d.ts +0 -5
- package/dist/tools/list-documents.js +0 -6
- package/dist/tools/list-endpoints.d.ts +1 -6
- package/dist/tools/list-endpoints.js +0 -6
- package/dist/tools/list-signals.d.ts +37 -0
- package/dist/tools/list-signals.js +83 -0
- package/dist/tools/manage-application.d.ts +64 -0
- package/dist/tools/manage-application.js +129 -0
- package/dist/tools/manage-diagram.d.ts +0 -5
- package/dist/tools/manage-diagram.js +0 -16
- package/dist/tools/manage-endpoint-lifecycle.d.ts +80 -0
- package/dist/tools/manage-endpoint-lifecycle.js +180 -0
- package/dist/tools/open-in-ide.d.ts +2 -14
- package/dist/tools/open-in-ide.js +0 -13
- package/dist/tools/review-change.d.ts +34 -0
- package/dist/tools/review-change.js +93 -0
- package/dist/tools/security-memory.d.ts +76 -0
- package/dist/tools/security-memory.js +202 -0
- package/dist/tools/security-review.d.ts +1 -21
- package/dist/tools/security-review.js +8 -108
- package/dist/tools/threat-get-capsule.d.ts +15 -0
- package/dist/tools/threat-get-capsule.js +53 -0
- package/dist/tools/threat-get-inference-prompt.d.ts +15 -0
- package/dist/tools/threat-get-inference-prompt.js +73 -0
- package/dist/tools/threat-list-relevant-capsules.d.ts +17 -0
- package/dist/tools/threat-list-relevant-capsules.js +158 -0
- package/dist/tools/threat-run-matcher.d.ts +17 -0
- package/dist/tools/threat-run-matcher.js +145 -0
- package/dist/tools/update-document.d.ts +0 -5
- package/dist/tools/update-document.js +3 -9
- package/dist/tools/update-endpoint.d.ts +1 -6
- package/dist/tools/update-endpoint.js +0 -7
- package/dist/tools/update-finding.d.ts +61 -0
- package/dist/tools/update-finding.js +80 -0
- package/dist/tools/update-mermaid-source.d.ts +0 -13
- package/dist/tools/update-mermaid-source.js +0 -14
- package/dist/tools/verify-trust-mark.d.ts +0 -5
- package/dist/tools/verify-trust-mark.js +0 -6
- package/dist/types.d.ts +14 -14
- package/dist/types.js +22 -28
- package/package.json +38 -15
- package/dist/api-client.js.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/jwt.js.map +0 -1
- package/dist/auth/keychain.js.map +0 -1
- package/dist/auth/oauth.js.map +0 -1
- package/dist/auth/sessions.js.map +0 -1
- package/dist/auth/token-refresh.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/project-binding.js.map +0 -1
- package/dist/resolve-application-id.js.map +0 -1
- package/dist/sanitize.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/tools/check-project.js.map +0 -1
- package/dist/tools/check-repo-trust.js.map +0 -1
- package/dist/tools/create-diagram.js.map +0 -1
- package/dist/tools/create-document.js.map +0 -1
- package/dist/tools/discover-local-infra.js.map +0 -1
- package/dist/tools/enterprise/capture-evidence.d.ts +0 -54
- package/dist/tools/enterprise/capture-evidence.js +0 -72
- package/dist/tools/enterprise/capture-evidence.js.map +0 -1
- package/dist/tools/enterprise/create-report-ticket.d.ts +0 -34
- package/dist/tools/enterprise/create-report-ticket.js +0 -44
- package/dist/tools/enterprise/create-report-ticket.js.map +0 -1
- package/dist/tools/enterprise/end-pentest-session.d.ts +0 -33
- package/dist/tools/enterprise/end-pentest-session.js +0 -42
- package/dist/tools/enterprise/end-pentest-session.js.map +0 -1
- package/dist/tools/enterprise/generate-report.d.ts +0 -55
- package/dist/tools/enterprise/generate-report.js +0 -111
- package/dist/tools/enterprise/generate-report.js.map +0 -1
- package/dist/tools/enterprise/get-org-zat.js.map +0 -1
- package/dist/tools/enterprise/get-report-status.d.ts +0 -27
- package/dist/tools/enterprise/get-report-status.js +0 -38
- package/dist/tools/enterprise/get-report-status.js.map +0 -1
- package/dist/tools/enterprise/get-threat-model.d.ts +0 -29
- package/dist/tools/enterprise/get-threat-model.js +0 -83
- package/dist/tools/enterprise/get-threat-model.js.map +0 -1
- package/dist/tools/enterprise/list-agents.d.ts +0 -42
- package/dist/tools/enterprise/list-agents.js +0 -95
- package/dist/tools/enterprise/list-agents.js.map +0 -1
- package/dist/tools/enterprise/list-report-issues.d.ts +0 -36
- package/dist/tools/enterprise/list-report-issues.js +0 -50
- package/dist/tools/enterprise/list-report-issues.js.map +0 -1
- package/dist/tools/enterprise/list-threat-models.d.ts +0 -36
- package/dist/tools/enterprise/list-threat-models.js +0 -82
- package/dist/tools/enterprise/list-threat-models.js.map +0 -1
- package/dist/tools/enterprise/manage-actor.d.ts +0 -58
- package/dist/tools/enterprise/manage-actor.js +0 -99
- package/dist/tools/enterprise/manage-actor.js.map +0 -1
- package/dist/tools/enterprise/manage-attack-scenario.d.ts +0 -70
- package/dist/tools/enterprise/manage-attack-scenario.js +0 -89
- package/dist/tools/enterprise/manage-attack-scenario.js.map +0 -1
- package/dist/tools/enterprise/manage-component.d.ts +0 -58
- package/dist/tools/enterprise/manage-component.js +0 -90
- package/dist/tools/enterprise/manage-component.js.map +0 -1
- package/dist/tools/enterprise/manage-data-asset.d.ts +0 -53
- package/dist/tools/enterprise/manage-data-asset.js +0 -90
- package/dist/tools/enterprise/manage-data-asset.js.map +0 -1
- package/dist/tools/enterprise/manage-data-flow.d.ts +0 -57
- package/dist/tools/enterprise/manage-data-flow.js +0 -98
- package/dist/tools/enterprise/manage-data-flow.js.map +0 -1
- package/dist/tools/enterprise/manage-finding.d.ts +0 -69
- package/dist/tools/enterprise/manage-finding.js +0 -106
- package/dist/tools/enterprise/manage-finding.js.map +0 -1
- package/dist/tools/enterprise/manage-security-control.d.ts +0 -59
- package/dist/tools/enterprise/manage-security-control.js +0 -96
- package/dist/tools/enterprise/manage-security-control.js.map +0 -1
- package/dist/tools/enterprise/manage-test-case.d.ts +0 -88
- package/dist/tools/enterprise/manage-test-case.js +0 -119
- package/dist/tools/enterprise/manage-test-case.js.map +0 -1
- package/dist/tools/enterprise/promote-finding-to-issue.d.ts +0 -36
- package/dist/tools/enterprise/promote-finding-to-issue.js +0 -65
- package/dist/tools/enterprise/promote-finding-to-issue.js.map +0 -1
- package/dist/tools/enterprise/publish-report-version.d.ts +0 -34
- package/dist/tools/enterprise/publish-report-version.js +0 -75
- package/dist/tools/enterprise/publish-report-version.js.map +0 -1
- package/dist/tools/enterprise/publish-test-to-library.d.ts +0 -31
- package/dist/tools/enterprise/publish-test-to-library.js +0 -40
- package/dist/tools/enterprise/publish-test-to-library.js.map +0 -1
- package/dist/tools/enterprise/record-test-result.d.ts +0 -67
- package/dist/tools/enterprise/record-test-result.js +0 -75
- package/dist/tools/enterprise/record-test-result.js.map +0 -1
- package/dist/tools/enterprise/start-pentest-session.d.ts +0 -35
- package/dist/tools/enterprise/start-pentest-session.js +0 -50
- package/dist/tools/enterprise/start-pentest-session.js.map +0 -1
- package/dist/tools/enterprise/sync-report-section.d.ts +0 -41
- package/dist/tools/enterprise/sync-report-section.js +0 -79
- package/dist/tools/enterprise/sync-report-section.js.map +0 -1
- package/dist/tools/enterprise/update-report-issue.d.ts +0 -55
- package/dist/tools/enterprise/update-report-issue.js +0 -69
- package/dist/tools/enterprise/update-report-issue.js.map +0 -1
- package/dist/tools/generate-diagram.js.map +0 -1
- package/dist/tools/get-agent-test-results.d.ts +0 -41
- package/dist/tools/get-agent-test-results.js +0 -86
- package/dist/tools/get-agent-test-results.js.map +0 -1
- package/dist/tools/get-application-overview.js.map +0 -1
- package/dist/tools/get-application.js.map +0 -1
- package/dist/tools/get-artifact-content.d.ts +0 -29
- package/dist/tools/get-artifact-content.js +0 -86
- package/dist/tools/get-artifact-content.js.map +0 -1
- package/dist/tools/get-diagram.js.map +0 -1
- package/dist/tools/get-document.js.map +0 -1
- package/dist/tools/get-finding-details.d.ts +0 -28
- package/dist/tools/get-finding-details.js +0 -43
- package/dist/tools/get-finding-details.js.map +0 -1
- package/dist/tools/get-findings.d.ts +0 -57
- package/dist/tools/get-findings.js +0 -103
- package/dist/tools/get-findings.js.map +0 -1
- package/dist/tools/get-oss-zat.js.map +0 -1
- package/dist/tools/get-recon-scan.d.ts +0 -27
- package/dist/tools/get-recon-scan.js +0 -46
- package/dist/tools/get-recon-scan.js.map +0 -1
- package/dist/tools/get-scan-output.d.ts +0 -27
- package/dist/tools/get-scan-output.js +0 -64
- package/dist/tools/get-scan-output.js.map +0 -1
- package/dist/tools/get-scenario-details.d.ts +0 -27
- package/dist/tools/get-scenario-details.js +0 -46
- package/dist/tools/get-scenario-details.js.map +0 -1
- package/dist/tools/get-test-case-results.d.ts +0 -37
- package/dist/tools/get-test-case-results.js +0 -66
- package/dist/tools/get-test-case-results.js.map +0 -1
- package/dist/tools/get-test-details.d.ts +0 -29
- package/dist/tools/get-test-details.js +0 -49
- package/dist/tools/get-test-details.js.map +0 -1
- package/dist/tools/get-trust-keys.js.map +0 -1
- package/dist/tools/import-openapi-endpoints.js.map +0 -1
- package/dist/tools/inspect-zat.js.map +0 -1
- package/dist/tools/list-agent-test-cases.d.ts +0 -41
- package/dist/tools/list-agent-test-cases.js +0 -73
- package/dist/tools/list-agent-test-cases.js.map +0 -1
- package/dist/tools/list-applications.js.map +0 -1
- package/dist/tools/list-diagrams.js.map +0 -1
- package/dist/tools/list-documents.js.map +0 -1
- package/dist/tools/list-endpoints.js.map +0 -1
- package/dist/tools/list-recon-scans.d.ts +0 -36
- package/dist/tools/list-recon-scans.js +0 -74
- package/dist/tools/list-recon-scans.js.map +0 -1
- package/dist/tools/list-scan-artifacts.d.ts +0 -41
- package/dist/tools/list-scan-artifacts.js +0 -63
- package/dist/tools/list-scan-artifacts.js.map +0 -1
- package/dist/tools/list-scans.d.ts +0 -44
- package/dist/tools/list-scans.js +0 -91
- package/dist/tools/list-scans.js.map +0 -1
- package/dist/tools/list-test-library.d.ts +0 -44
- package/dist/tools/list-test-library.js +0 -83
- package/dist/tools/list-test-library.js.map +0 -1
- package/dist/tools/list-test-scenarios.d.ts +0 -31
- package/dist/tools/list-test-scenarios.js +0 -66
- package/dist/tools/list-test-scenarios.js.map +0 -1
- package/dist/tools/local-scan.d.ts +0 -40
- package/dist/tools/local-scan.js +0 -261
- package/dist/tools/local-scan.js.map +0 -1
- package/dist/tools/manage-diagram.js.map +0 -1
- package/dist/tools/open-in-ide.js.map +0 -1
- package/dist/tools/run-test-scenario.d.ts +0 -37
- package/dist/tools/run-test-scenario.js +0 -70
- package/dist/tools/run-test-scenario.js.map +0 -1
- package/dist/tools/scan-pr.d.ts +0 -27
- package/dist/tools/scan-pr.js +0 -51
- package/dist/tools/scan-pr.js.map +0 -1
- package/dist/tools/security-review.js.map +0 -1
- package/dist/tools/setup-red-team-target.d.ts +0 -79
- package/dist/tools/setup-red-team-target.js +0 -430
- package/dist/tools/setup-red-team-target.js.map +0 -1
- package/dist/tools/triage-finding.d.ts +0 -47
- package/dist/tools/triage-finding.js +0 -116
- package/dist/tools/triage-finding.js.map +0 -1
- package/dist/tools/update-document.js.map +0 -1
- package/dist/tools/update-endpoint.js.map +0 -1
- package/dist/tools/update-mermaid-source.js.map +0 -1
- package/dist/tools/verify-trust-mark.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const THREAT_LIST_RELEVANT_CAPSULES_NAME = "zivis_threat_list_relevant_capsules";
|
|
3
|
+
export declare const THREAT_LIST_RELEVANT_CAPSULES_DESCRIPTION = "List threat-model patterns relevant to the user's current repo.\n\nUse this when the user asks any of:\n- \"what should I be worried about in this code\"\n- \"what threats apply to my app\"\n- \"are there known patterns that match my architecture\"\n- \"what's in my threat model\"\n- mid-conversation when the user describes a feature that touches deps the threat library covers\n\nReads the latest local repo graph artifact (produced by 'zivis inspect') from the user cache, runs every capsule's relevance_filter against it, and returns the subset whose filter passes \u2014 together with each capsule's safe_summary so you can frame the conversation in threat-model terms (component, flow, trust boundary, scenario).\n\nIf no graph artifact exists yet for this repo, the tool returns a next-step pointing to 'zivis inspect'. Always speak in threat-model vocabulary even when the user doesn't.";
|
|
4
|
+
export declare const THREAT_LIST_RELEVANT_CAPSULES_SCHEMA: {
|
|
5
|
+
artifact_path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
7
|
+
};
|
|
8
|
+
export declare function createThreatListRelevantCapsulesHandler(): (params: {
|
|
9
|
+
artifact_path?: string;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
content: Array<{
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
}>;
|
|
16
|
+
isError?: boolean;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as fssync from "node:fs";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { loadActivePack, findRelevantCapsules, } from "../pattern-pack/index.js";
|
|
7
|
+
import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
|
|
8
|
+
export const THREAT_LIST_RELEVANT_CAPSULES_NAME = "zivis_threat_list_relevant_capsules";
|
|
9
|
+
export const THREAT_LIST_RELEVANT_CAPSULES_DESCRIPTION = `List threat-model patterns relevant to the user's current repo.
|
|
10
|
+
|
|
11
|
+
Use this when the user asks any of:
|
|
12
|
+
- "what should I be worried about in this code"
|
|
13
|
+
- "what threats apply to my app"
|
|
14
|
+
- "are there known patterns that match my architecture"
|
|
15
|
+
- "what's in my threat model"
|
|
16
|
+
- mid-conversation when the user describes a feature that touches deps the threat library covers
|
|
17
|
+
|
|
18
|
+
Reads the latest local repo graph artifact (produced by 'zivis inspect') from the user cache, runs every capsule's relevance_filter against it, and returns the subset whose filter passes — together with each capsule's safe_summary so you can frame the conversation in threat-model terms (component, flow, trust boundary, scenario).
|
|
19
|
+
|
|
20
|
+
If no graph artifact exists yet for this repo, the tool returns a next-step pointing to 'zivis inspect'. Always speak in threat-model vocabulary even when the user doesn't.`;
|
|
21
|
+
export const THREAT_LIST_RELEVANT_CAPSULES_SCHEMA = {
|
|
22
|
+
artifact_path: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Optional path to a specific RepoGraphArtifactV1 JSON. If omitted, the tool finds the most recent artifact in ~/Library/Caches/zivis/repos/<repo-id>/inspect/runs/ for the repo at cwd."),
|
|
26
|
+
cwd: z
|
|
27
|
+
.string()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Working directory whose repo cache to search (defaults to server cwd)."),
|
|
30
|
+
};
|
|
31
|
+
export function createThreatListRelevantCapsulesHandler() {
|
|
32
|
+
return async (params) => {
|
|
33
|
+
const cwd = params.cwd ?? process.cwd();
|
|
34
|
+
let artifact;
|
|
35
|
+
let artifactPath;
|
|
36
|
+
try {
|
|
37
|
+
const resolved = await resolveArtifactPath(params.artifact_path, cwd);
|
|
38
|
+
artifactPath = resolved;
|
|
39
|
+
const raw = await fs.readFile(resolved, "utf8");
|
|
40
|
+
artifact = JSON.parse(raw);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
return withNextStepsError(`No repo graph artifact found. ${err.message}`, [
|
|
44
|
+
{
|
|
45
|
+
id: "run_zivis_inspect",
|
|
46
|
+
label: "Run `zivis inspect` to build the local repo graph",
|
|
47
|
+
tool: "zivis_inspect",
|
|
48
|
+
why: "The relevance evaluation reads from the latest inspect run in the user cache.",
|
|
49
|
+
},
|
|
50
|
+
], "Run `zivis inspect` first; this tool reads from its output.");
|
|
51
|
+
}
|
|
52
|
+
const handle = await loadActivePack();
|
|
53
|
+
const relevant = await findRelevantCapsules(handle, artifact);
|
|
54
|
+
const summaries = relevant.map((cap) => ({
|
|
55
|
+
id: cap.id,
|
|
56
|
+
title: cap.title,
|
|
57
|
+
category: cap.category,
|
|
58
|
+
safe_summary: cap.safe_summary,
|
|
59
|
+
applicable_languages: cap.applicable_languages,
|
|
60
|
+
matched_on: matchedTerms(cap, artifact),
|
|
61
|
+
}));
|
|
62
|
+
return withNextSteps({
|
|
63
|
+
artifact_path: artifactPath,
|
|
64
|
+
pack: { id: handle.manifest.pack_id, version: handle.manifest.version },
|
|
65
|
+
languages_in_scope: artifact.scope.languages ?? [],
|
|
66
|
+
relevant_count: summaries.length,
|
|
67
|
+
relevant_capsules: summaries,
|
|
68
|
+
}, summaries.length > 0
|
|
69
|
+
? [
|
|
70
|
+
{
|
|
71
|
+
id: "get_capsule_details",
|
|
72
|
+
label: "Pull the full capsule for any item the user wants to investigate",
|
|
73
|
+
tool: "zivis_threat_get_capsule",
|
|
74
|
+
why: "The full capsule has threats (with STRIDE), risk_hints, repair_contract, related_patterns.",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "get_inference_prompt",
|
|
78
|
+
label: "Get the inference prompt for the host LLM to run a deeper check",
|
|
79
|
+
tool: "zivis_threat_get_inference_prompt",
|
|
80
|
+
why: "INFER strategies in each capsule reference a prompt template the user's IDE model executes.",
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
: [
|
|
84
|
+
{
|
|
85
|
+
id: "no_relevant_patterns",
|
|
86
|
+
label: "No public-pack patterns matched this repo",
|
|
87
|
+
tool: "zivis_threat_list_relevant_capsules",
|
|
88
|
+
why: "This is normal for repos without agentic / RAG / self-consistency / multi-tenant patterns. Proprietary patterns may still apply server-side.",
|
|
89
|
+
},
|
|
90
|
+
], summaries.length > 0
|
|
91
|
+
? `Found ${summaries.length} relevant capsule(s) in the threat library.`
|
|
92
|
+
: "No public-pack capsules matched this repo. Proprietary patterns evaluated server-side may still apply.");
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function userCacheRoot() {
|
|
96
|
+
const home = os.homedir();
|
|
97
|
+
if (process.platform === "darwin") {
|
|
98
|
+
return path.join(home, "Library", "Caches", "zivis");
|
|
99
|
+
}
|
|
100
|
+
if (process.platform === "win32") {
|
|
101
|
+
const localAppData = process.env.LOCALAPPDATA ?? path.join(home, "AppData", "Local");
|
|
102
|
+
return path.join(localAppData, "zivis", "Cache");
|
|
103
|
+
}
|
|
104
|
+
const xdg = process.env.XDG_CACHE_HOME;
|
|
105
|
+
return path.join(xdg ?? path.join(home, ".cache"), "zivis");
|
|
106
|
+
}
|
|
107
|
+
async function resolveArtifactPath(explicit, cwd) {
|
|
108
|
+
if (explicit) {
|
|
109
|
+
if (!fssync.existsSync(explicit)) {
|
|
110
|
+
throw new Error(`Artifact path does not exist: ${explicit}`);
|
|
111
|
+
}
|
|
112
|
+
return explicit;
|
|
113
|
+
}
|
|
114
|
+
const reposRoot = path.join(userCacheRoot(), "repos");
|
|
115
|
+
if (!fssync.existsSync(reposRoot)) {
|
|
116
|
+
throw new Error(`No inspect cache found at ${reposRoot}. Run \`zivis inspect\` from the repo to populate it.`);
|
|
117
|
+
}
|
|
118
|
+
const candidates = [];
|
|
119
|
+
for (const repo of await fs.readdir(reposRoot, { withFileTypes: true })) {
|
|
120
|
+
if (!repo.isDirectory())
|
|
121
|
+
continue;
|
|
122
|
+
const runs = path.join(reposRoot, repo.name, "inspect", "runs");
|
|
123
|
+
if (!fssync.existsSync(runs))
|
|
124
|
+
continue;
|
|
125
|
+
for (const entry of await fs.readdir(runs)) {
|
|
126
|
+
if (!entry.endsWith(".json"))
|
|
127
|
+
continue;
|
|
128
|
+
const full = path.join(runs, entry);
|
|
129
|
+
const stat = await fs.stat(full);
|
|
130
|
+
candidates.push({ file: full, mtime: stat.mtimeMs });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (candidates.length === 0) {
|
|
134
|
+
throw new Error(`No inspect runs found under ${reposRoot}. Run \`zivis inspect\` from the repo to produce one.`);
|
|
135
|
+
}
|
|
136
|
+
candidates.sort((a, b) => b.mtime - a.mtime);
|
|
137
|
+
return candidates[0].file;
|
|
138
|
+
}
|
|
139
|
+
function matchedTerms(cap, artifact) {
|
|
140
|
+
const matched = [];
|
|
141
|
+
const pkgs = new Set();
|
|
142
|
+
for (const node of artifact.nodes) {
|
|
143
|
+
if (node.type === "external_dependency" && node.attributes?.package) {
|
|
144
|
+
pkgs.add(node.attributes.package);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const langs = new Set(artifact.scope.languages ?? []);
|
|
148
|
+
const f = cap.relevance_filter;
|
|
149
|
+
if (!f)
|
|
150
|
+
return ["always-applicable (no relevance_filter set)"];
|
|
151
|
+
for (const term of [...(f.any_of ?? []), ...(f.all_of ?? [])]) {
|
|
152
|
+
if (term.dependency && pkgs.has(term.dependency))
|
|
153
|
+
matched.push(`dep:${term.dependency}`);
|
|
154
|
+
if (term.language && langs.has(term.language))
|
|
155
|
+
matched.push(`language:${term.language}`);
|
|
156
|
+
}
|
|
157
|
+
return matched.length > 0 ? matched : ["language match only"];
|
|
158
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const THREAT_RUN_MATCHER_NAME = "zivis_threat_run_matcher";
|
|
3
|
+
export declare const THREAT_RUN_MATCHER_DESCRIPTION = "Run the local pattern matcher against the latest repo graph artifact and emit normalized threat findings.\n\nUse this when:\n- The user asks ZIVIS to actually evaluate (not just list) which patterns fire on their code\n- After 'zivis inspect' has produced an artifact and the user wants concrete findings\n- \"find security issues in my code\", \"check this against the threat library\", \"what's actually wrong here\"\n\nPhase 3 v1 evaluates AST strategies for real (via @ast-grep/napi for TS/JS, plus Python and Go via dynamic language packs). INFER strategies emit a candidate the host LLM is expected to pick up via zivis_threat_get_inference_prompt and run with its own model. GRAPH / META / DEP / CONFIG strategies are surfaced as fired_strategies with match_count: 0 \u2014 visible-but-not-evaluated for now.\n\nLane assignment per finding:\n- trusted: count of fired deterministic strategies meets the capsule's required_evidence_count\n- inferred: at least one strategy fired but the bar wasn't met (host should run inference to confirm)\n\nThe output is a normalized findings array with pattern_id, lane, confidence, evidence spans, and (for inferred-lane findings) an inference_candidate the host LLM uses to run deeper analysis.";
|
|
4
|
+
export declare const THREAT_RUN_MATCHER_SCHEMA: {
|
|
5
|
+
artifact_path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
7
|
+
};
|
|
8
|
+
export declare function createThreatRunMatcherHandler(): (params: {
|
|
9
|
+
artifact_path?: string;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
content: Array<{
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
}>;
|
|
16
|
+
isError?: boolean;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as fssync from "node:fs";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import * as crypto from "node:crypto";
|
|
7
|
+
import { exec } from "node:child_process";
|
|
8
|
+
import { promisify } from "node:util";
|
|
9
|
+
import { runMatcher } from "../matcher/index.js";
|
|
10
|
+
import { buildInferenceBundle } from "../matcher/inference-candidates.js";
|
|
11
|
+
import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
|
|
12
|
+
const execAsync = promisify(exec);
|
|
13
|
+
export const THREAT_RUN_MATCHER_NAME = "zivis_threat_run_matcher";
|
|
14
|
+
export const THREAT_RUN_MATCHER_DESCRIPTION = `Run the local pattern matcher against the latest repo graph artifact and emit normalized threat findings.
|
|
15
|
+
|
|
16
|
+
Use this when:
|
|
17
|
+
- The user asks ZIVIS to actually evaluate (not just list) which patterns fire on their code
|
|
18
|
+
- After 'zivis inspect' has produced an artifact and the user wants concrete findings
|
|
19
|
+
- "find security issues in my code", "check this against the threat library", "what's actually wrong here"
|
|
20
|
+
|
|
21
|
+
Phase 3 v1 evaluates AST strategies for real (via @ast-grep/napi for TS/JS, plus Python and Go via dynamic language packs). INFER strategies emit a candidate the host LLM is expected to pick up via zivis_threat_get_inference_prompt and run with its own model. GRAPH / META / DEP / CONFIG strategies are surfaced as fired_strategies with match_count: 0 — visible-but-not-evaluated for now.
|
|
22
|
+
|
|
23
|
+
Lane assignment per finding:
|
|
24
|
+
- trusted: count of fired deterministic strategies meets the capsule's required_evidence_count
|
|
25
|
+
- inferred: at least one strategy fired but the bar wasn't met (host should run inference to confirm)
|
|
26
|
+
|
|
27
|
+
The output is a normalized findings array with pattern_id, lane, confidence, evidence spans, and (for inferred-lane findings) an inference_candidate the host LLM uses to run deeper analysis.`;
|
|
28
|
+
export const THREAT_RUN_MATCHER_SCHEMA = {
|
|
29
|
+
artifact_path: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Path to a specific RepoGraphArtifactV1 JSON. If omitted, the most recent inspect run in the user cache is used."),
|
|
33
|
+
cwd: z
|
|
34
|
+
.string()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Repo root for source-file walking — capsule AST strategies match against files in this directory. Defaults to server cwd."),
|
|
37
|
+
};
|
|
38
|
+
export function createThreatRunMatcherHandler() {
|
|
39
|
+
return async (params) => {
|
|
40
|
+
const cwd = params.cwd ?? process.cwd();
|
|
41
|
+
let artifactPath;
|
|
42
|
+
try {
|
|
43
|
+
artifactPath = await resolveArtifactPath(params.artifact_path, cwd);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return withNextStepsError(`No repo graph artifact found. ${err.message}`, [
|
|
47
|
+
{
|
|
48
|
+
id: "run_zivis_inspect",
|
|
49
|
+
label: "Run `zivis inspect` to build the local repo graph first",
|
|
50
|
+
tool: "zivis_inspect",
|
|
51
|
+
why: "The matcher consumes the latest inspect artifact.",
|
|
52
|
+
},
|
|
53
|
+
], "Run `zivis inspect` first; this tool reads from its output.");
|
|
54
|
+
}
|
|
55
|
+
const result = await runMatcher({ artifactPath, cwd });
|
|
56
|
+
const inferenceBundle = await buildInferenceBundle(result.findings);
|
|
57
|
+
const headline = result.summary.total === 0
|
|
58
|
+
? "Matcher ran cleanly — no patterns fired against this repo."
|
|
59
|
+
: `Matcher emitted ${result.summary.total} finding(s): ${result.summary.trusted_count} trusted, ${result.summary.inferred_count} inferred. ` +
|
|
60
|
+
(inferenceBundle.inference_candidates.length > 0
|
|
61
|
+
? `IMPORTANT: ${inferenceBundle.inference_candidates.length} inference_candidate${inferenceBundle.inference_candidates.length === 1 ? "" : "s"} require host-side execution — see host_required_action.`
|
|
62
|
+
: "");
|
|
63
|
+
return withNextSteps({
|
|
64
|
+
...result,
|
|
65
|
+
host_required_action: inferenceBundle.host_required_action,
|
|
66
|
+
inference_candidates: inferenceBundle.inference_candidates,
|
|
67
|
+
}, result.summary.inferred_count > 0
|
|
68
|
+
? [
|
|
69
|
+
{
|
|
70
|
+
id: "get_inference_prompts",
|
|
71
|
+
label: "Pull inference prompts for inferred-lane findings and run them in your model",
|
|
72
|
+
tool: "zivis_threat_get_inference_prompt",
|
|
73
|
+
why: "Each inferred finding has an inference_candidate.prompt_ref. Pass it (or the capsule_id) to retrieve the prompt bundle.",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "review_findings",
|
|
77
|
+
label: "Review the trusted-lane findings first; they're evidence-backed and ready for the threat model",
|
|
78
|
+
tool: "zivis_threat_run_matcher",
|
|
79
|
+
why: "Trusted-lane findings can land in the threat model directly. Inferred require host-LLM confirmation.",
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
: result.summary.total === 0
|
|
83
|
+
? [
|
|
84
|
+
{
|
|
85
|
+
id: "expand_pack",
|
|
86
|
+
label: "No matches today — proprietary patterns evaluated server-side may still apply",
|
|
87
|
+
tool: "zivis_threat_run_matcher",
|
|
88
|
+
why: "Public pack covers a curated subset. Phase 4 sends the artifact for proprietary platform evaluation.",
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
: [], headline);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function userCacheRoot() {
|
|
95
|
+
const home = os.homedir();
|
|
96
|
+
if (process.platform === "darwin") {
|
|
97
|
+
return path.join(home, "Library", "Caches", "zivis");
|
|
98
|
+
}
|
|
99
|
+
if (process.platform === "win32") {
|
|
100
|
+
const localAppData = process.env.LOCALAPPDATA ?? path.join(home, "AppData", "Local");
|
|
101
|
+
return path.join(localAppData, "zivis", "Cache");
|
|
102
|
+
}
|
|
103
|
+
const xdg = process.env.XDG_CACHE_HOME;
|
|
104
|
+
return path.join(xdg ?? path.join(home, ".cache"), "zivis");
|
|
105
|
+
}
|
|
106
|
+
async function resolveArtifactPath(explicit, cwd) {
|
|
107
|
+
if (explicit) {
|
|
108
|
+
if (!fssync.existsSync(explicit)) {
|
|
109
|
+
throw new Error(`Artifact path does not exist: ${explicit}`);
|
|
110
|
+
}
|
|
111
|
+
return explicit;
|
|
112
|
+
}
|
|
113
|
+
const repoId = await deriveRepoId(cwd);
|
|
114
|
+
const runsDir = path.join(userCacheRoot(), "repos", repoId, "inspect", "runs");
|
|
115
|
+
if (!fssync.existsSync(runsDir)) {
|
|
116
|
+
throw new Error(`No inspect runs for this repo (looked under ${runsDir}). Run \`zivis inspect\` from this directory first.`);
|
|
117
|
+
}
|
|
118
|
+
const candidates = [];
|
|
119
|
+
for (const entry of await fs.readdir(runsDir)) {
|
|
120
|
+
if (!entry.endsWith(".json"))
|
|
121
|
+
continue;
|
|
122
|
+
const full = path.join(runsDir, entry);
|
|
123
|
+
const stat = await fs.stat(full);
|
|
124
|
+
candidates.push({ file: full, mtime: stat.mtimeMs });
|
|
125
|
+
}
|
|
126
|
+
if (candidates.length === 0) {
|
|
127
|
+
throw new Error(`No inspect runs found under ${runsDir}.`);
|
|
128
|
+
}
|
|
129
|
+
candidates.sort((a, b) => b.mtime - a.mtime);
|
|
130
|
+
return candidates[0].file;
|
|
131
|
+
}
|
|
132
|
+
async function deriveRepoId(cwd) {
|
|
133
|
+
try {
|
|
134
|
+
const { stdout } = await execAsync("git remote get-url origin", { cwd });
|
|
135
|
+
const remote = stdout.trim();
|
|
136
|
+
if (remote)
|
|
137
|
+
return "remote-" + sha256Short(remote);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
}
|
|
141
|
+
return "path-" + sha256Short(cwd);
|
|
142
|
+
}
|
|
143
|
+
function sha256Short(value) {
|
|
144
|
+
return crypto.createHash("sha256").update(value).digest("hex").slice(0, 16);
|
|
145
|
+
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_update_document — Update a document's title, markdown content, or tags.
|
|
3
|
-
*
|
|
4
|
-
* Maps to: PATCH /api/documents/:id
|
|
5
|
-
*/
|
|
6
1
|
import { z } from "zod";
|
|
7
2
|
import type { ApiClient } from "../api-client.js";
|
|
8
3
|
export declare const UPDATE_DOCUMENT_NAME = "zivis_update_document";
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_update_document — Update a document's title, markdown content, or tags.
|
|
3
|
-
*
|
|
4
|
-
* Maps to: PATCH /api/documents/:id
|
|
5
|
-
*/
|
|
6
1
|
import { z } from "zod";
|
|
7
|
-
import { sanitizeResponse } from "../sanitize.js";
|
|
2
|
+
import { sanitizeResponse, sanitizeInboundText } from "../sanitize.js";
|
|
8
3
|
export const UPDATE_DOCUMENT_NAME = "zivis_update_document";
|
|
9
4
|
export const UPDATE_DOCUMENT_DESCRIPTION = `Update a document's title, markdown content, or tags. At least one of these fields must be provided.
|
|
10
5
|
|
|
@@ -47,9 +42,9 @@ export function createUpdateDocumentHandler(apiClient) {
|
|
|
47
42
|
}
|
|
48
43
|
const body = {};
|
|
49
44
|
if (title !== undefined)
|
|
50
|
-
body.title = title;
|
|
45
|
+
body.title = sanitizeInboundText(title, 500);
|
|
51
46
|
if (content !== undefined)
|
|
52
|
-
body.content = content;
|
|
47
|
+
body.content = sanitizeInboundText(content, 200_000);
|
|
53
48
|
if (tags !== undefined)
|
|
54
49
|
body.tags = tags;
|
|
55
50
|
const data = await apiClient.patch(`/api/documents/${document_id}`, body);
|
|
@@ -60,4 +55,3 @@ export function createUpdateDocumentHandler(apiClient) {
|
|
|
60
55
|
}
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
|
-
//# sourceMappingURL=update-document.js.map
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_update_endpoint — Update a specific endpoint's configuration
|
|
3
|
-
*
|
|
4
|
-
* Maps to: PATCH /api/rt/applications/:id/endpoints/:endpointId
|
|
5
|
-
*/
|
|
6
1
|
import { z } from "zod";
|
|
7
2
|
import type { ApiClient } from "../api-client.js";
|
|
8
3
|
export declare const UPDATE_ENDPOINT_NAME = "zivis_update_endpoint";
|
|
@@ -15,8 +10,8 @@ export declare const UPDATE_ENDPOINT_SCHEMA: {
|
|
|
15
10
|
POST: "POST";
|
|
16
11
|
GET: "GET";
|
|
17
12
|
PATCH: "PATCH";
|
|
18
|
-
DELETE: "DELETE";
|
|
19
13
|
PUT: "PUT";
|
|
14
|
+
DELETE: "DELETE";
|
|
20
15
|
HEAD: "HEAD";
|
|
21
16
|
OPTIONS: "OPTIONS";
|
|
22
17
|
}>>;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_update_endpoint — Update a specific endpoint's configuration
|
|
3
|
-
*
|
|
4
|
-
* Maps to: PATCH /api/rt/applications/:id/endpoints/:endpointId
|
|
5
|
-
*/
|
|
6
1
|
import { z } from "zod";
|
|
7
2
|
import { requireApplicationId } from "../resolve-application-id.js";
|
|
8
3
|
import { sanitizeResponse } from "../sanitize.js";
|
|
@@ -79,7 +74,6 @@ export function createUpdateEndpointHandler(apiClient) {
|
|
|
79
74
|
}
|
|
80
75
|
const application_id = req.id;
|
|
81
76
|
const apiPath = `/api/rt/applications/${application_id}/endpoints/${params.endpoint_id}`;
|
|
82
|
-
// Map snake_case params to camelCase API fields, only including provided values
|
|
83
77
|
const body = {};
|
|
84
78
|
if (params.path !== undefined)
|
|
85
79
|
body.path = params.path;
|
|
@@ -142,4 +136,3 @@ export function createUpdateEndpointHandler(apiClient) {
|
|
|
142
136
|
}
|
|
143
137
|
};
|
|
144
138
|
}
|
|
145
|
-
//# sourceMappingURL=update-endpoint.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ApiClient } from "../api-client.js";
|
|
3
|
+
export declare const UPDATE_FINDING_NAME = "zivis_update_finding";
|
|
4
|
+
export declare const UPDATE_FINDING_DESCRIPTION = "Update an existing security finding \u2014 edit its fields or change its status.\n\nUse to correct or flesh out a finding (title, severity, description, category, remediation, CWE/OWASP), or to move it through its lifecycle (triaged, resolved, dismissed, suppressed). Only pass the fields you want to change. Every change is audited. Pass the finding's id (from zivis_create_finding or the findings list). To delete a finding, use zivis_delete_finding instead.";
|
|
5
|
+
export declare const UPDATE_FINDING_SCHEMA: {
|
|
6
|
+
finding_id: z.ZodString;
|
|
7
|
+
title: z.ZodOptional<z.ZodString>;
|
|
8
|
+
severity: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
critical: "critical";
|
|
10
|
+
high: "high";
|
|
11
|
+
medium: "medium";
|
|
12
|
+
low: "low";
|
|
13
|
+
info: "info";
|
|
14
|
+
}>>;
|
|
15
|
+
description: z.ZodOptional<z.ZodString>;
|
|
16
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
vulnerability: "vulnerability";
|
|
18
|
+
misconfiguration: "misconfiguration";
|
|
19
|
+
secret: "secret";
|
|
20
|
+
anomaly: "anomaly";
|
|
21
|
+
other: "other";
|
|
22
|
+
}>>;
|
|
23
|
+
remediation_steps: z.ZodOptional<z.ZodString>;
|
|
24
|
+
cwe_id: z.ZodOptional<z.ZodString>;
|
|
25
|
+
owasp_id: z.ZodOptional<z.ZodString>;
|
|
26
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
27
|
+
open: "open";
|
|
28
|
+
in_progress: "in_progress";
|
|
29
|
+
resolved: "resolved";
|
|
30
|
+
dismissed: "dismissed";
|
|
31
|
+
triaged: "triaged";
|
|
32
|
+
suppressed: "suppressed";
|
|
33
|
+
}>>;
|
|
34
|
+
dismiss_reason: z.ZodOptional<z.ZodEnum<{
|
|
35
|
+
false_positive: "false_positive";
|
|
36
|
+
risk_accepted: "risk_accepted";
|
|
37
|
+
duplicate: "duplicate";
|
|
38
|
+
wont_fix: "wont_fix";
|
|
39
|
+
}>>;
|
|
40
|
+
note: z.ZodOptional<z.ZodString>;
|
|
41
|
+
};
|
|
42
|
+
type UpdateFindingParams = {
|
|
43
|
+
finding_id: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
severity?: "critical" | "high" | "medium" | "low" | "info";
|
|
46
|
+
description?: string;
|
|
47
|
+
category?: "vulnerability" | "misconfiguration" | "secret" | "anomaly" | "other";
|
|
48
|
+
remediation_steps?: string;
|
|
49
|
+
cwe_id?: string;
|
|
50
|
+
owasp_id?: string;
|
|
51
|
+
status?: "open" | "triaged" | "in_progress" | "resolved" | "dismissed" | "suppressed";
|
|
52
|
+
dismiss_reason?: "false_positive" | "risk_accepted" | "duplicate" | "wont_fix";
|
|
53
|
+
note?: string;
|
|
54
|
+
};
|
|
55
|
+
export declare function createUpdateFindingHandler(apiClient: ApiClient): (params: UpdateFindingParams) => Promise<{
|
|
56
|
+
content: {
|
|
57
|
+
type: "text";
|
|
58
|
+
text: string;
|
|
59
|
+
}[];
|
|
60
|
+
}>;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { sanitizeResponse, sanitizeInboundText } from "../sanitize.js";
|
|
3
|
+
export const UPDATE_FINDING_NAME = "zivis_update_finding";
|
|
4
|
+
export const UPDATE_FINDING_DESCRIPTION = `Update an existing security finding — edit its fields or change its status.
|
|
5
|
+
|
|
6
|
+
Use to correct or flesh out a finding (title, severity, description, category, remediation, CWE/OWASP), or to move it through its lifecycle (triaged, resolved, dismissed, suppressed). Only pass the fields you want to change. Every change is audited. Pass the finding's id (from zivis_create_finding or the findings list). To delete a finding, use zivis_delete_finding instead.`;
|
|
7
|
+
export const UPDATE_FINDING_SCHEMA = {
|
|
8
|
+
finding_id: z.string().describe("UUID of the finding to update"),
|
|
9
|
+
title: z.string().optional().describe("New title"),
|
|
10
|
+
severity: z
|
|
11
|
+
.enum(["critical", "high", "medium", "low", "info"])
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("New severity"),
|
|
14
|
+
description: z.string().optional().describe("New description / details (markdown allowed)"),
|
|
15
|
+
category: z
|
|
16
|
+
.enum(["vulnerability", "misconfiguration", "secret", "anomaly", "other"])
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("New category"),
|
|
19
|
+
remediation_steps: z.string().optional().describe("New remediation guidance"),
|
|
20
|
+
cwe_id: z.string().optional().describe("CWE id, e.g. 'CWE-89'"),
|
|
21
|
+
owasp_id: z.string().optional().describe("OWASP id, e.g. 'A01'"),
|
|
22
|
+
status: z
|
|
23
|
+
.enum(["open", "triaged", "in_progress", "resolved", "dismissed", "suppressed"])
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("New lifecycle status. Use zivis_delete_finding to delete."),
|
|
26
|
+
dismiss_reason: z
|
|
27
|
+
.enum(["false_positive", "risk_accepted", "duplicate", "wont_fix"])
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Reason, when status=dismissed"),
|
|
30
|
+
note: z.string().optional().describe("Optional note recorded in the audit history"),
|
|
31
|
+
};
|
|
32
|
+
function errorResult(message) {
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
35
|
+
isError: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function successResult(data) {
|
|
39
|
+
return {
|
|
40
|
+
content: [{ type: "text", text: JSON.stringify(sanitizeResponse(data), null, 2) }],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function createUpdateFindingHandler(apiClient) {
|
|
44
|
+
return async (params) => {
|
|
45
|
+
try {
|
|
46
|
+
if (!params.finding_id || !params.finding_id.trim()) {
|
|
47
|
+
return errorResult("finding_id is required");
|
|
48
|
+
}
|
|
49
|
+
const body = {};
|
|
50
|
+
if (params.title !== undefined)
|
|
51
|
+
body.title = sanitizeInboundText(params.title, 500);
|
|
52
|
+
if (params.severity !== undefined)
|
|
53
|
+
body.severity = params.severity;
|
|
54
|
+
if (params.description !== undefined)
|
|
55
|
+
body.description = sanitizeInboundText(params.description, 8000);
|
|
56
|
+
if (params.category !== undefined)
|
|
57
|
+
body.category = params.category;
|
|
58
|
+
if (params.remediation_steps !== undefined)
|
|
59
|
+
body.remediationSteps = sanitizeInboundText(params.remediation_steps, 4000);
|
|
60
|
+
if (params.cwe_id !== undefined)
|
|
61
|
+
body.cweId = params.cwe_id;
|
|
62
|
+
if (params.owasp_id !== undefined)
|
|
63
|
+
body.owaspId = params.owasp_id;
|
|
64
|
+
if (params.status !== undefined)
|
|
65
|
+
body.status = params.status;
|
|
66
|
+
if (params.dismiss_reason !== undefined)
|
|
67
|
+
body.dismissReason = sanitizeInboundText(params.dismiss_reason, 2000);
|
|
68
|
+
if (params.note !== undefined)
|
|
69
|
+
body.note = sanitizeInboundText(params.note, 4000);
|
|
70
|
+
if (Object.keys(body).length === 0) {
|
|
71
|
+
return errorResult("Provide at least one field to update");
|
|
72
|
+
}
|
|
73
|
+
const data = await apiClient.patch(`/api/findings/unified/${encodeURIComponent(params.finding_id)}`, body);
|
|
74
|
+
return successResult(data);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
return errorResult(err?.message ?? "Failed to update finding");
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_update_mermaid_source — Update the Mermaid source of a diagram
|
|
3
|
-
*
|
|
4
|
-
* Maps to: PATCH /api/diagrams/:id with { content: <mermaidSource> }
|
|
5
|
-
*
|
|
6
|
-
* Workflow for an editing AI:
|
|
7
|
-
* 1. Call zivis_get_diagram with the diagram_id — returns current content (Mermaid text) + metadata.
|
|
8
|
-
* 2. Reason about the change the user requested. Produce a new Mermaid source string.
|
|
9
|
-
* 3. Call this tool with the new source to persist it.
|
|
10
|
-
*
|
|
11
|
-
* Use this for diagrams whose contentType is "mermaid". For canvas/node diagrams
|
|
12
|
-
* (contentType = "canvas"), use zivis_manage_diagram instead.
|
|
13
|
-
*/
|
|
14
1
|
import { z } from "zod";
|
|
15
2
|
import type { ApiClient } from "../api-client.js";
|
|
16
3
|
export declare const UPDATE_MERMAID_SOURCE_NAME = "zivis_update_mermaid_source";
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_update_mermaid_source — Update the Mermaid source of a diagram
|
|
3
|
-
*
|
|
4
|
-
* Maps to: PATCH /api/diagrams/:id with { content: <mermaidSource> }
|
|
5
|
-
*
|
|
6
|
-
* Workflow for an editing AI:
|
|
7
|
-
* 1. Call zivis_get_diagram with the diagram_id — returns current content (Mermaid text) + metadata.
|
|
8
|
-
* 2. Reason about the change the user requested. Produce a new Mermaid source string.
|
|
9
|
-
* 3. Call this tool with the new source to persist it.
|
|
10
|
-
*
|
|
11
|
-
* Use this for diagrams whose contentType is "mermaid". For canvas/node diagrams
|
|
12
|
-
* (contentType = "canvas"), use zivis_manage_diagram instead.
|
|
13
|
-
*/
|
|
14
1
|
import { z } from "zod";
|
|
15
2
|
import { sanitizeResponse } from "../sanitize.js";
|
|
16
3
|
export const UPDATE_MERMAID_SOURCE_NAME = "zivis_update_mermaid_source";
|
|
@@ -73,4 +60,3 @@ export function createUpdateMermaidSourceHandler(apiClient) {
|
|
|
73
60
|
}
|
|
74
61
|
};
|
|
75
62
|
}
|
|
76
|
-
//# sourceMappingURL=update-mermaid-source.js.map
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_verify_trust_mark — Verify a trust mark by hash or compact token
|
|
3
|
-
*
|
|
4
|
-
* Maps to: GET /api/verify/:hash OR GET /api/verify-token/:token (public, no auth)
|
|
5
|
-
*/
|
|
6
1
|
import { z } from "zod";
|
|
7
2
|
import type { ZivisConfig } from "../types.js";
|
|
8
3
|
export declare const VERIFY_TRUST_MARK_NAME = "zivis_verify_trust_mark";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zivis_verify_trust_mark — Verify a trust mark by hash or compact token
|
|
3
|
-
*
|
|
4
|
-
* Maps to: GET /api/verify/:hash OR GET /api/verify-token/:token (public, no auth)
|
|
5
|
-
*/
|
|
6
1
|
import { z } from "zod";
|
|
7
2
|
export const VERIFY_TRUST_MARK_NAME = "zivis_verify_trust_mark";
|
|
8
3
|
export const VERIFY_TRUST_MARK_DESCRIPTION = `Verify a ZIVIS Trust Mark by its SHA-256 hash or Ed25519 compact token.
|
|
@@ -105,4 +100,3 @@ export function createVerifyTrustMarkHandler(config) {
|
|
|
105
100
|
}
|
|
106
101
|
};
|
|
107
102
|
}
|
|
108
|
-
//# sourceMappingURL=verify-trust-mark.js.map
|