nowaikit 2.5.3 → 3.0.0
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/dist/cli/index.js +89 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/direct/executor.d.ts +28 -0
- package/dist/direct/executor.d.ts.map +1 -0
- package/dist/direct/executor.js +228 -0
- package/dist/direct/executor.js.map +1 -0
- package/dist/direct/llm-client.d.ts +32 -0
- package/dist/direct/llm-client.d.ts.map +1 -0
- package/dist/direct/llm-client.js +122 -0
- package/dist/direct/llm-client.js.map +1 -0
- package/dist/prompts/capabilities/build-app.d.ts +4 -0
- package/dist/prompts/capabilities/build-app.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-app.js +238 -0
- package/dist/prompts/capabilities/build-app.js.map +1 -0
- package/dist/prompts/capabilities/build-business-rule.d.ts +4 -0
- package/dist/prompts/capabilities/build-business-rule.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-business-rule.js +93 -0
- package/dist/prompts/capabilities/build-business-rule.js.map +1 -0
- package/dist/prompts/capabilities/build-catalog.d.ts +4 -0
- package/dist/prompts/capabilities/build-catalog.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-catalog.js +350 -0
- package/dist/prompts/capabilities/build-catalog.js.map +1 -0
- package/dist/prompts/capabilities/build-client-script.d.ts +4 -0
- package/dist/prompts/capabilities/build-client-script.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-client-script.js +157 -0
- package/dist/prompts/capabilities/build-client-script.js.map +1 -0
- package/dist/prompts/capabilities/build-flow.d.ts +4 -0
- package/dist/prompts/capabilities/build-flow.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-flow.js +243 -0
- package/dist/prompts/capabilities/build-flow.js.map +1 -0
- package/dist/prompts/capabilities/build-portal.d.ts +4 -0
- package/dist/prompts/capabilities/build-portal.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-portal.js +250 -0
- package/dist/prompts/capabilities/build-portal.js.map +1 -0
- package/dist/prompts/capabilities/build-rest-api.d.ts +4 -0
- package/dist/prompts/capabilities/build-rest-api.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-rest-api.js +293 -0
- package/dist/prompts/capabilities/build-rest-api.js.map +1 -0
- package/dist/prompts/capabilities/build-test-plan.d.ts +4 -0
- package/dist/prompts/capabilities/build-test-plan.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-test-plan.js +162 -0
- package/dist/prompts/capabilities/build-test-plan.js.map +1 -0
- package/dist/prompts/capabilities/build-uib.d.ts +4 -0
- package/dist/prompts/capabilities/build-uib.d.ts.map +1 -0
- package/dist/prompts/capabilities/build-uib.js +309 -0
- package/dist/prompts/capabilities/build-uib.js.map +1 -0
- package/dist/prompts/capabilities/docs-app.d.ts +4 -0
- package/dist/prompts/capabilities/docs-app.d.ts.map +1 -0
- package/dist/prompts/capabilities/docs-app.js +234 -0
- package/dist/prompts/capabilities/docs-app.js.map +1 -0
- package/dist/prompts/capabilities/docs-release.d.ts +4 -0
- package/dist/prompts/capabilities/docs-release.d.ts.map +1 -0
- package/dist/prompts/capabilities/docs-release.js +197 -0
- package/dist/prompts/capabilities/docs-release.js.map +1 -0
- package/dist/prompts/capabilities/docs-runbook.d.ts +4 -0
- package/dist/prompts/capabilities/docs-runbook.d.ts.map +1 -0
- package/dist/prompts/capabilities/docs-runbook.js +223 -0
- package/dist/prompts/capabilities/docs-runbook.js.map +1 -0
- package/dist/prompts/capabilities/docs-script.d.ts +4 -0
- package/dist/prompts/capabilities/docs-script.d.ts.map +1 -0
- package/dist/prompts/capabilities/docs-script.js +242 -0
- package/dist/prompts/capabilities/docs-script.js.map +1 -0
- package/dist/prompts/capabilities/ops-deploy.d.ts +4 -0
- package/dist/prompts/capabilities/ops-deploy.d.ts.map +1 -0
- package/dist/prompts/capabilities/ops-deploy.js +193 -0
- package/dist/prompts/capabilities/ops-deploy.js.map +1 -0
- package/dist/prompts/capabilities/ops-risk.d.ts +4 -0
- package/dist/prompts/capabilities/ops-risk.d.ts.map +1 -0
- package/dist/prompts/capabilities/ops-risk.js +227 -0
- package/dist/prompts/capabilities/ops-risk.js.map +1 -0
- package/dist/prompts/capabilities/ops-triage.d.ts +4 -0
- package/dist/prompts/capabilities/ops-triage.d.ts.map +1 -0
- package/dist/prompts/capabilities/ops-triage.js +183 -0
- package/dist/prompts/capabilities/ops-triage.js.map +1 -0
- package/dist/prompts/capabilities/review-acls.d.ts +4 -0
- package/dist/prompts/capabilities/review-acls.d.ts.map +1 -0
- package/dist/prompts/capabilities/review-acls.js +142 -0
- package/dist/prompts/capabilities/review-acls.js.map +1 -0
- package/dist/prompts/capabilities/review-code.d.ts +4 -0
- package/dist/prompts/capabilities/review-code.d.ts.map +1 -0
- package/dist/prompts/capabilities/review-code.js +155 -0
- package/dist/prompts/capabilities/review-code.js.map +1 -0
- package/dist/prompts/capabilities/review-flows.d.ts +4 -0
- package/dist/prompts/capabilities/review-flows.d.ts.map +1 -0
- package/dist/prompts/capabilities/review-flows.js +413 -0
- package/dist/prompts/capabilities/review-flows.js.map +1 -0
- package/dist/prompts/capabilities/review-scripts.d.ts +4 -0
- package/dist/prompts/capabilities/review-scripts.d.ts.map +1 -0
- package/dist/prompts/capabilities/review-scripts.js +160 -0
- package/dist/prompts/capabilities/review-scripts.js.map +1 -0
- package/dist/prompts/capabilities/scan-automation.d.ts +4 -0
- package/dist/prompts/capabilities/scan-automation.d.ts.map +1 -0
- package/dist/prompts/capabilities/scan-automation.js +449 -0
- package/dist/prompts/capabilities/scan-automation.js.map +1 -0
- package/dist/prompts/capabilities/scan-cmdb.d.ts +4 -0
- package/dist/prompts/capabilities/scan-cmdb.d.ts.map +1 -0
- package/dist/prompts/capabilities/scan-cmdb.js +450 -0
- package/dist/prompts/capabilities/scan-cmdb.js.map +1 -0
- package/dist/prompts/capabilities/scan-debt.d.ts +4 -0
- package/dist/prompts/capabilities/scan-debt.d.ts.map +1 -0
- package/dist/prompts/capabilities/scan-debt.js +287 -0
- package/dist/prompts/capabilities/scan-debt.js.map +1 -0
- package/dist/prompts/capabilities/scan-health.d.ts +4 -0
- package/dist/prompts/capabilities/scan-health.d.ts.map +1 -0
- package/dist/prompts/capabilities/scan-health.js +235 -0
- package/dist/prompts/capabilities/scan-health.js.map +1 -0
- package/dist/prompts/capabilities/scan-security.d.ts +4 -0
- package/dist/prompts/capabilities/scan-security.d.ts.map +1 -0
- package/dist/prompts/capabilities/scan-security.js +370 -0
- package/dist/prompts/capabilities/scan-security.js.map +1 -0
- package/dist/prompts/capabilities/scan-upgrade.d.ts +4 -0
- package/dist/prompts/capabilities/scan-upgrade.d.ts.map +1 -0
- package/dist/prompts/capabilities/scan-upgrade.js +327 -0
- package/dist/prompts/capabilities/scan-upgrade.js.map +1 -0
- package/dist/prompts/index.d.ts +24 -2
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +160 -14
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/knowledge.d.ts +10 -0
- package/dist/prompts/knowledge.d.ts.map +1 -0
- package/dist/prompts/knowledge.js +604 -0
- package/dist/prompts/knowledge.js.map +1 -0
- package/dist/prompts/types.d.ts +38 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +8 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/dist/servicenow/client.d.ts +15 -0
- package/dist/servicenow/client.d.ts.map +1 -1
- package/dist/servicenow/client.js +107 -0
- package/dist/servicenow/client.js.map +1 -1
- package/dist/tools/core.d.ts +68 -0
- package/dist/tools/core.d.ts.map +1 -1
- package/dist/tools/core.js +58 -0
- package/dist/tools/core.js.map +1 -1
- package/dist/tools/fluent.d.ts +161 -0
- package/dist/tools/fluent.d.ts.map +1 -0
- package/dist/tools/fluent.js +277 -0
- package/dist/tools/fluent.js.map +1 -0
- package/dist/tools/index.d.ts +214 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +12 -6
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/now-assist.d.ts.map +1 -1
- package/dist/tools/now-assist.js +8 -0
- package/dist/tools/now-assist.js.map +1 -1
- package/dist/tools/script.d.ts.map +1 -1
- package/dist/tools/script.js +12 -0
- package/dist/tools/script.js.map +1 -1
- package/package.json +11 -3
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
const capability = {
|
|
2
|
+
name: 'scan-security',
|
|
3
|
+
title: 'Security Audit',
|
|
4
|
+
description: 'Comprehensive security scan \u2014 ACLs, roles, scripts, APIs, compliance across ALL artifact types',
|
|
5
|
+
category: 'scan',
|
|
6
|
+
arguments: [
|
|
7
|
+
{
|
|
8
|
+
name: 'scope',
|
|
9
|
+
description: 'Audit scope: "instance" for full audit, or a specific table/app name for targeted audit',
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'focus',
|
|
14
|
+
description: 'Narrow the audit focus: "acls", "roles", "scripts", "api", or "all" (default)',
|
|
15
|
+
required: false,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
recommendedTools: [
|
|
19
|
+
'list_acls',
|
|
20
|
+
'get_acl',
|
|
21
|
+
'list_users',
|
|
22
|
+
'list_groups',
|
|
23
|
+
'list_business_rules',
|
|
24
|
+
'list_script_includes',
|
|
25
|
+
'list_client_scripts',
|
|
26
|
+
'list_ui_policies',
|
|
27
|
+
'list_ui_actions',
|
|
28
|
+
'list_rest_messages',
|
|
29
|
+
'list_oauth_applications',
|
|
30
|
+
'query_records',
|
|
31
|
+
'get_table_schema',
|
|
32
|
+
],
|
|
33
|
+
buildPrompt(args) {
|
|
34
|
+
const scope = args?.scope ?? 'instance';
|
|
35
|
+
const focus = args?.focus ?? 'all';
|
|
36
|
+
const isFullInstance = scope === 'instance';
|
|
37
|
+
const scopeLabel = isFullInstance
|
|
38
|
+
? 'Full instance security audit'
|
|
39
|
+
: `Targeted security audit of \`${scope}\``;
|
|
40
|
+
const focusLabel = {
|
|
41
|
+
all: 'All security domains',
|
|
42
|
+
acls: 'ACLs & access control',
|
|
43
|
+
roles: 'Roles & user privileges',
|
|
44
|
+
scripts: 'Script security (server + client)',
|
|
45
|
+
api: 'API & integration security',
|
|
46
|
+
};
|
|
47
|
+
const focusDescription = focusLabel[focus] ?? `Custom focus: ${focus}`;
|
|
48
|
+
// ─── ACL Section ──────────────────────────────────────────────────────────
|
|
49
|
+
const aclSection = [
|
|
50
|
+
'## 1. ACL Security Analysis',
|
|
51
|
+
'',
|
|
52
|
+
'Use `list_acls`, `get_acl`, `query_records`, and `get_table_schema` to scan:',
|
|
53
|
+
'',
|
|
54
|
+
'### Missing ACLs',
|
|
55
|
+
'- Tables with custom data but NO ACLs defined (query `sys_db_object` cross-referenced with `sys_security_acl`)',
|
|
56
|
+
'- Tables with record-level ACLs but no field-level ACLs on sensitive fields (e.g., `password`, `email`, `ssn`)',
|
|
57
|
+
'- CRUD operations missing coverage (table has read ACL but no create/write/delete)',
|
|
58
|
+
'',
|
|
59
|
+
'### Overly Permissive ACLs',
|
|
60
|
+
'- ACLs with empty conditions and no script (unconditional access)',
|
|
61
|
+
'- ACLs granting access to all roles via `*` wildcard',
|
|
62
|
+
'- ACLs where the only check is `gs.hasRole("admin")` (admin-only shortcut)',
|
|
63
|
+
'- ACLs with `advanced: false` and no condition (default allow)',
|
|
64
|
+
'- Read ACLs that expose all fields without field-level restrictions',
|
|
65
|
+
'',
|
|
66
|
+
'### Dangerous Patterns',
|
|
67
|
+
'- ACLs with `setWorkflow(false)` that skip other security checks',
|
|
68
|
+
'- ACLs with `type: record` that have no condition and no script',
|
|
69
|
+
'- Duplicate ACLs (same table + operation + role combination)',
|
|
70
|
+
'- ACLs on `sys_*` tables that weaken platform security',
|
|
71
|
+
'',
|
|
72
|
+
'**Output per finding:**',
|
|
73
|
+
'| Finding ID | Severity | ACL Name | Table | Operation | Issue | Recommendation |',
|
|
74
|
+
];
|
|
75
|
+
// ─── Role Section ─────────────────────────────────────────────────────────
|
|
76
|
+
const roleSection = [
|
|
77
|
+
'## 2. Role & Privilege Analysis',
|
|
78
|
+
'',
|
|
79
|
+
'Use `list_users`, `list_groups`, and `query_records` on `sys_user_has_role`, `sys_user_role`, `sys_group_has_role` to scan:',
|
|
80
|
+
'',
|
|
81
|
+
'### Admin Overuse',
|
|
82
|
+
'- Count of users with `admin` role (flag if > 10 or > 2% of total users)',
|
|
83
|
+
'- Service accounts with `admin` (should use scoped roles)',
|
|
84
|
+
'- Groups with `admin` role (every member inherits it)',
|
|
85
|
+
'- Users with admin who have not logged in for 90+ days',
|
|
86
|
+
'',
|
|
87
|
+
'### Role Explosion',
|
|
88
|
+
'- Total custom role count (flag if > 200)',
|
|
89
|
+
'- Roles with no users or groups assigned (orphan roles)',
|
|
90
|
+
'- Roles that contain other roles with conflicting permissions',
|
|
91
|
+
'- Deeply nested role hierarchies (> 3 levels deep)',
|
|
92
|
+
'',
|
|
93
|
+
'### Privilege Escalation Risks',
|
|
94
|
+
'- Custom roles that inherit from `admin` or `security_admin`',
|
|
95
|
+
'- Roles granting access to `sys_script`, `sys_security_acl`, or `sys_user_has_role` tables',
|
|
96
|
+
'- Users with both `impersonator` and elevated roles',
|
|
97
|
+
'- Separation of duty violations (e.g., same user can create and approve changes)',
|
|
98
|
+
'',
|
|
99
|
+
'**Output per finding:**',
|
|
100
|
+
'| Finding ID | Severity | Role/User | Issue | Risk | Recommendation |',
|
|
101
|
+
];
|
|
102
|
+
// ─── Server Script Section ────────────────────────────────────────────────
|
|
103
|
+
const serverScriptSection = [
|
|
104
|
+
'## 3. Server-Side Script Security',
|
|
105
|
+
'',
|
|
106
|
+
'Use `list_business_rules`, `list_script_includes`, `list_scheduled_jobs`, and `query_records` to scan',
|
|
107
|
+
'ALL server-side scriptable artifact types:',
|
|
108
|
+
'',
|
|
109
|
+
'### Artifact Types to Scan',
|
|
110
|
+
'- **Business Rules** (`sys_script`) \u2014 before/after/async/display',
|
|
111
|
+
'- **Script Includes** (`sys_script_include`) \u2014 classPrototype, on-demand, used by BRs/flows',
|
|
112
|
+
'- **Fix Scripts** (`sys_script_fix`) \u2014 one-time execution scripts',
|
|
113
|
+
'- **Scheduled Jobs** (`sysauto_script`) \u2014 recurring server scripts',
|
|
114
|
+
'- **MID Server Script Includes** (`ecc_agent_script_include`)',
|
|
115
|
+
'- **Script Actions** (`sysevent_script_action`) \u2014 event-driven scripts',
|
|
116
|
+
'- **Processors** (`sys_processor`) \u2014 custom URL handlers',
|
|
117
|
+
'- **Transform Map Scripts** (`sys_transform_script`) \u2014 onBefore/onAfter/onForeignInsert',
|
|
118
|
+
'- **REST Message Functions** (`sys_rest_message_fn`) \u2014 scripted HTTP methods',
|
|
119
|
+
'- **Scripted REST Resources** (`sys_ws_operation`) \u2014 custom API endpoints',
|
|
120
|
+
'',
|
|
121
|
+
'### Patterns to Flag',
|
|
122
|
+
'- **Code injection:** `eval()`, `GlideEvaluator`, `GlideScopedEvaluator` with dynamic input',
|
|
123
|
+
'- **SQL/GlideRecord injection:** string concatenation in `addQuery()` or `addEncodedQuery()`',
|
|
124
|
+
'- **Credential exposure:** hardcoded passwords, API keys, tokens, connection strings',
|
|
125
|
+
'- **Insecure imports:** `Packages.java.*`, `GlideHTTPClient` without TLS validation',
|
|
126
|
+
'- **ACL bypass:** `setWorkflow(false)`, `autoSysFields(false)` without justification',
|
|
127
|
+
'- **Missing input validation:** `current.getValue()` used directly in queries without sanitization',
|
|
128
|
+
'- **Dangerous GlideSystem calls:** `gs.include()` with dynamic names, `gs.xmlToJSON()` with untrusted input',
|
|
129
|
+
'- **Privilege escalation:** scripts that elevate roles or modify ACL tables',
|
|
130
|
+
'- **Logging sensitive data:** `gs.log()` / `gs.debug()` with passwords or PII',
|
|
131
|
+
'',
|
|
132
|
+
'**Output per finding:**',
|
|
133
|
+
'| Finding ID | Severity | Artifact Type | Name | Sys ID | Pattern Found | Line/Evidence | Recommendation |',
|
|
134
|
+
];
|
|
135
|
+
// ─── Client Script Section ────────────────────────────────────────────────
|
|
136
|
+
const clientScriptSection = [
|
|
137
|
+
'## 4. Client-Side Script Security',
|
|
138
|
+
'',
|
|
139
|
+
'Use `list_client_scripts`, `list_ui_policies`, `list_ui_actions`, and `query_records` to scan',
|
|
140
|
+
'ALL client-side scriptable artifact types:',
|
|
141
|
+
'',
|
|
142
|
+
'### Artifact Types to Scan',
|
|
143
|
+
'- **Client Scripts** (`sys_script_client`) \u2014 onLoad, onChange, onSubmit, onCellEdit',
|
|
144
|
+
'- **UI Policies** (`sys_ui_policy`) \u2014 with script actions',
|
|
145
|
+
'- **UI Actions** (`sys_ui_action`) \u2014 with client=true or onclick scripts',
|
|
146
|
+
'- **UI Pages** (`sys_ui_page`) \u2014 processing scripts, client scripts, HTML',
|
|
147
|
+
'- **UI Macros** (`sys_ui_macro`) \u2014 Jelly template scripts',
|
|
148
|
+
'- **Catalog Client Scripts** (`catalog_script_client`)',
|
|
149
|
+
'- **Catalog UI Policies** (`catalog_ui_policy`)',
|
|
150
|
+
'',
|
|
151
|
+
'### Patterns to Flag',
|
|
152
|
+
'- **XSS vulnerabilities:** `innerHTML`, `document.write()`, `jQuery.html()` with dynamic content',
|
|
153
|
+
'- **Data exposure:** client scripts fetching sensitive fields (password, SSN, salary) via GlideAjax',
|
|
154
|
+
'- **Client-only validation:** form validation without server-side enforcement in Business Rules',
|
|
155
|
+
'- **Hardcoded values:** URLs, sys_ids, credentials embedded in client scripts',
|
|
156
|
+
'- **DOM manipulation:** direct DOM access that may break across UI versions',
|
|
157
|
+
'- **Excessive GlideAjax:** multiple synchronous server calls in a single script',
|
|
158
|
+
'- **Console logging:** `console.log()`, `jslog()` exposing internal data',
|
|
159
|
+
'- **Eval usage:** `eval()`, `new Function()`, `setTimeout` with string arguments',
|
|
160
|
+
'',
|
|
161
|
+
'**Output per finding:**',
|
|
162
|
+
'| Finding ID | Severity | Artifact Type | Name | Pattern Found | Evidence | Recommendation |',
|
|
163
|
+
];
|
|
164
|
+
// ─── Flows & Automation Section ───────────────────────────────────────────
|
|
165
|
+
const flowSection = [
|
|
166
|
+
'## 5. Flows & Automation Security',
|
|
167
|
+
'',
|
|
168
|
+
'Use `query_records` on `sys_hub_flow`, `sys_hub_action_instance`, and legacy `wf_workflow` to scan:',
|
|
169
|
+
'',
|
|
170
|
+
'- **Flow Actions** with inline scripts \u2014 same script patterns as server scripts',
|
|
171
|
+
'- **Subflows** running as System \u2014 should use least-privilege run-as',
|
|
172
|
+
'- **Legacy Workflows** (`wf_workflow`) with Run Script activities',
|
|
173
|
+
'- **Flow triggers** on sensitive tables without condition filters',
|
|
174
|
+
'- **Credential usage** in flows \u2014 plain-text vs credential alias',
|
|
175
|
+
'- **Spoke actions** calling external systems without TLS verification',
|
|
176
|
+
'',
|
|
177
|
+
'**Output per finding:**',
|
|
178
|
+
'| Finding ID | Severity | Flow/Workflow Name | Issue | Recommendation |',
|
|
179
|
+
];
|
|
180
|
+
// ─── API Section ──────────────────────────────────────────────────────────
|
|
181
|
+
const apiSection = [
|
|
182
|
+
'## 6. API & Integration Security',
|
|
183
|
+
'',
|
|
184
|
+
'Use `list_rest_messages`, `list_oauth_applications`, and `query_records` to scan:',
|
|
185
|
+
'',
|
|
186
|
+
'### REST & SOAP',
|
|
187
|
+
'- **REST Messages** (`sys_rest_message`) with basic auth over HTTP (not HTTPS)',
|
|
188
|
+
'- **Scripted REST APIs** (`sys_ws_operation`) without ACL or role requirements',
|
|
189
|
+
'- **REST endpoints** returning excessive data (no field selection, no pagination)',
|
|
190
|
+
'- **SOAP endpoints** still active but unused',
|
|
191
|
+
'',
|
|
192
|
+
'### OAuth & Credentials',
|
|
193
|
+
'- **OAuth applications** with overly broad scopes',
|
|
194
|
+
'- **OAuth tokens** with no expiration or very long lifetimes',
|
|
195
|
+
'- **Credential aliases** unused or referencing stale credentials',
|
|
196
|
+
'- **Basic auth profiles** that should be migrated to OAuth',
|
|
197
|
+
'',
|
|
198
|
+
'### Data Exposure',
|
|
199
|
+
'- **API endpoints** returning sensitive fields (password, SSN, etc.)',
|
|
200
|
+
'- **Missing rate limiting** on public-facing APIs',
|
|
201
|
+
'- **CORS misconfiguration** (`glide.rest.cors.*` properties)',
|
|
202
|
+
'- **API versioning** \u2014 deprecated API versions still active',
|
|
203
|
+
'',
|
|
204
|
+
'**Output per finding:**',
|
|
205
|
+
'| Finding ID | Severity | API Name | Type | Issue | Recommendation |',
|
|
206
|
+
];
|
|
207
|
+
// ─── Portal Section ──────────────────────────────────────────────────────
|
|
208
|
+
const portalSection = [
|
|
209
|
+
'## 7. Portal & UI Security',
|
|
210
|
+
'',
|
|
211
|
+
'Use `query_records` on `sp_widget`, `sp_angular_provider`, `sp_page`, `sys_portal_page` to scan:',
|
|
212
|
+
'',
|
|
213
|
+
'- **SP Widgets** with inline `<script>` tags or `ng-bind-html` without `$sce.trustAsHtml` filtering',
|
|
214
|
+
'- **Angular Providers** exposing server-side data without access control',
|
|
215
|
+
'- **Widget server scripts** that query sensitive tables without role checks',
|
|
216
|
+
'- **Client controllers** with `$http` calls bypassing standard API',
|
|
217
|
+
'- **Portal pages** with embedded iframes to external domains',
|
|
218
|
+
'- **CSS injection** via unvalidated user input in widget options',
|
|
219
|
+
'',
|
|
220
|
+
'**Output per finding:**',
|
|
221
|
+
'| Finding ID | Severity | Widget/Page Name | Issue | Recommendation |',
|
|
222
|
+
];
|
|
223
|
+
// ─── Integration Section ──────────────────────────────────────────────────
|
|
224
|
+
const integrationSection = [
|
|
225
|
+
'## 8. Integration & Data Pipeline Security',
|
|
226
|
+
'',
|
|
227
|
+
'Use `query_records` on `sys_transform_map`, `sys_import_set`, `sys_data_source` to scan:',
|
|
228
|
+
'',
|
|
229
|
+
'- **Transform Maps** with onBefore/onAfter scripts containing injection risks',
|
|
230
|
+
'- **Import Sets** from untrusted external sources without validation',
|
|
231
|
+
'- **Data Sources** using FTP or unencrypted protocols',
|
|
232
|
+
'- **MID Server** integrations without certificate pinning',
|
|
233
|
+
'- **LDAP/SSO** configurations with fallback to local auth',
|
|
234
|
+
'',
|
|
235
|
+
'**Output per finding:**',
|
|
236
|
+
'| Finding ID | Severity | Integration Name | Type | Issue | Recommendation |',
|
|
237
|
+
];
|
|
238
|
+
// ─── Notification Section ─────────────────────────────────────────────────
|
|
239
|
+
const notificationSection = [
|
|
240
|
+
'## 9. Notification Security',
|
|
241
|
+
'',
|
|
242
|
+
'Use `query_records` on `sysevent_email_action`, `sys_email_template`, `sys_email` to scan:',
|
|
243
|
+
'',
|
|
244
|
+
'- **Email notifications** with scripted conditions exposing sensitive data in mail body',
|
|
245
|
+
'- **Email templates** with Jelly/Angular expressions that can be exploited (template injection)',
|
|
246
|
+
'- **Mail scripts** (`sys_script_email`) querying sensitive fields for email body',
|
|
247
|
+
'- **Notifications** sent to external domains with internal data',
|
|
248
|
+
'- **SMS/Push** notifications with sensitive field references',
|
|
249
|
+
'',
|
|
250
|
+
'**Output per finding:**',
|
|
251
|
+
'| Finding ID | Severity | Notification Name | Issue | Recommendation |',
|
|
252
|
+
];
|
|
253
|
+
// ─── Build sections based on focus ────────────────────────────────────────
|
|
254
|
+
let sections;
|
|
255
|
+
switch (focus) {
|
|
256
|
+
case 'acls':
|
|
257
|
+
sections = [aclSection];
|
|
258
|
+
break;
|
|
259
|
+
case 'roles':
|
|
260
|
+
sections = [roleSection];
|
|
261
|
+
break;
|
|
262
|
+
case 'scripts':
|
|
263
|
+
sections = [serverScriptSection, clientScriptSection, flowSection];
|
|
264
|
+
break;
|
|
265
|
+
case 'api':
|
|
266
|
+
sections = [apiSection, integrationSection];
|
|
267
|
+
break;
|
|
268
|
+
default:
|
|
269
|
+
sections = [
|
|
270
|
+
aclSection,
|
|
271
|
+
roleSection,
|
|
272
|
+
serverScriptSection,
|
|
273
|
+
clientScriptSection,
|
|
274
|
+
flowSection,
|
|
275
|
+
apiSection,
|
|
276
|
+
portalSection,
|
|
277
|
+
integrationSection,
|
|
278
|
+
notificationSection,
|
|
279
|
+
];
|
|
280
|
+
}
|
|
281
|
+
// ─── Report Format ────────────────────────────────────────────────────────
|
|
282
|
+
const reportFormat = [
|
|
283
|
+
'## Security Audit Report Format',
|
|
284
|
+
'',
|
|
285
|
+
'Compile ALL findings into this structure:',
|
|
286
|
+
'',
|
|
287
|
+
'```',
|
|
288
|
+
'SECURITY AUDIT REPORT',
|
|
289
|
+
'======================',
|
|
290
|
+
`Scope: ${isFullInstance ? 'Full instance' : scope}`,
|
|
291
|
+
`Focus: ${focusDescription}`,
|
|
292
|
+
'Date: [current date]',
|
|
293
|
+
'',
|
|
294
|
+
'EXECUTIVE SUMMARY',
|
|
295
|
+
'- Critical findings: X',
|
|
296
|
+
'- High findings: X',
|
|
297
|
+
'- Medium findings: X',
|
|
298
|
+
'- Low findings: X',
|
|
299
|
+
'- Overall risk rating: [Critical / High / Medium / Low]',
|
|
300
|
+
'',
|
|
301
|
+
'DETAILED FINDINGS',
|
|
302
|
+
'-----------------',
|
|
303
|
+
'Each finding MUST include:',
|
|
304
|
+
' Finding ID: SEC-XXXX',
|
|
305
|
+
' Severity: Critical / High / Medium / Low',
|
|
306
|
+
' Category: ACL / Role / Server Script / Client Script / Flow / API / Portal / Integration / Notification',
|
|
307
|
+
' Artifact: [type] — [name] (sys_id)',
|
|
308
|
+
' Evidence: [exact code snippet, configuration value, or query result]',
|
|
309
|
+
' Risk: [what an attacker could exploit]',
|
|
310
|
+
' Recommendation: [specific fix with code example where applicable]',
|
|
311
|
+
'',
|
|
312
|
+
'SEVERITY DEFINITIONS',
|
|
313
|
+
' CRITICAL — Exploitable now; data breach or privilege escalation possible',
|
|
314
|
+
' HIGH — Exploitable with moderate effort; significant data exposure',
|
|
315
|
+
' MEDIUM — Weakness that could be chained with other issues',
|
|
316
|
+
' LOW — Best-practice violation; minimal direct risk',
|
|
317
|
+
'',
|
|
318
|
+
'REMEDIATION PRIORITIES',
|
|
319
|
+
'1. [Critical items — fix immediately]',
|
|
320
|
+
'2. [High items — fix within 1 week]',
|
|
321
|
+
'3. [Medium items — fix within 1 month]',
|
|
322
|
+
'4. [Low items — address in next review cycle]',
|
|
323
|
+
'',
|
|
324
|
+
'COMPLIANCE NOTES',
|
|
325
|
+
'- [Any SOX, HIPAA, GDPR, SOC2 implications]',
|
|
326
|
+
'```',
|
|
327
|
+
];
|
|
328
|
+
return [
|
|
329
|
+
{
|
|
330
|
+
role: 'assistant',
|
|
331
|
+
content: {
|
|
332
|
+
type: 'text',
|
|
333
|
+
text: [
|
|
334
|
+
'# Capability: Security Audit',
|
|
335
|
+
'',
|
|
336
|
+
`**Scope:** ${scopeLabel}`,
|
|
337
|
+
`**Focus:** ${focusDescription}`,
|
|
338
|
+
'',
|
|
339
|
+
'This capability performs a comprehensive security audit covering EVERY scriptable',
|
|
340
|
+
'and configurable artifact type in the ServiceNow instance. The audit is exhaustive \u2014',
|
|
341
|
+
'it does not stop at ACLs and roles but inspects every place where security gaps can hide.',
|
|
342
|
+
'',
|
|
343
|
+
'CRITICAL INSTRUCTION: You must scan ALL artifact types listed below, not just the',
|
|
344
|
+
'common ones. Security gaps often hide in overlooked areas like transform map scripts,',
|
|
345
|
+
'UI macros, catalog client scripts, and email templates.',
|
|
346
|
+
'',
|
|
347
|
+
...sections.flatMap(s => [...s, '']),
|
|
348
|
+
...reportFormat,
|
|
349
|
+
'',
|
|
350
|
+
'---',
|
|
351
|
+
'',
|
|
352
|
+
'Beginning security audit. Every finding must include its Finding ID, severity,',
|
|
353
|
+
'category, concrete evidence, and a specific recommendation.',
|
|
354
|
+
].join('\n'),
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
role: 'user',
|
|
359
|
+
content: {
|
|
360
|
+
type: 'text',
|
|
361
|
+
text: isFullInstance
|
|
362
|
+
? `Run a comprehensive security audit on my ServiceNow instance. Focus: ${focus}. Scan every artifact type and give me a structured report with finding IDs and severity ratings.`
|
|
363
|
+
: `Run a targeted security audit on \`${scope}\`. Focus: ${focus}. Scan every relevant artifact type and give me a structured report with finding IDs and severity ratings.`,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
];
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
export default capability;
|
|
370
|
+
//# sourceMappingURL=scan-security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-security.js","sourceRoot":"","sources":["../../../src/prompts/capabilities/scan-security.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAyB;IACvC,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,gBAAgB;IACvB,WAAW,EACT,qGAAqG;IACvG,QAAQ,EAAE,MAAM;IAEhB,SAAS,EAAE;QACT;YACE,IAAI,EAAE,OAAO;YACb,WAAW,EACT,yFAAyF;YAC3F,QAAQ,EAAE,IAAI;SACf;QACD;YACE,IAAI,EAAE,OAAO;YACb,WAAW,EACT,+EAA+E;YACjF,QAAQ,EAAE,KAAK;SAChB;KACF;IAED,gBAAgB,EAAE;QAChB,WAAW;QACX,SAAS;QACT,YAAY;QACZ,aAAa;QACb,qBAAqB;QACrB,sBAAsB;QACtB,qBAAqB;QACrB,kBAAkB;QAClB,iBAAiB;QACjB,oBAAoB;QACpB,yBAAyB;QACzB,eAAe;QACf,kBAAkB;KACnB;IAED,WAAW,CAAC,IAAI;QACd,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,UAAU,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,KAAK,CAAC;QAEnC,MAAM,cAAc,GAAG,KAAK,KAAK,UAAU,CAAC;QAC5C,MAAM,UAAU,GAAG,cAAc;YAC/B,CAAC,CAAC,8BAA8B;YAChC,CAAC,CAAC,gCAAgC,KAAK,IAAI,CAAC;QAE9C,MAAM,UAAU,GAA2B;YACzC,GAAG,EAAE,sBAAsB;YAC3B,IAAI,EAAE,uBAAuB;YAC7B,KAAK,EAAE,yBAAyB;YAChC,OAAO,EAAE,mCAAmC;YAC5C,GAAG,EAAE,4BAA4B;SAClC,CAAC;QAEF,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CA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e;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,cAAc;wBAClB,CAAC,CAAC,wEAAwE,KAAK,mGAAmG;wBAClL,CAAC,CAAC,sCAAsC,KAAK,cAAc,KAAK,4GAA4G;iBAC/K;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-upgrade.d.ts","sourceRoot":"","sources":["../../../src/prompts/capabilities/scan-upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,QAAA,MAAM,UAAU,EAAE,oBA8VjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|