snow-flow 2.0.2 → 2.0.4
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/{.claude/mcp-config.json → .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +48 -1
- package/package.json +1 -1
- package/.claude/claude-settings.json +0 -15
- package/.claude/commands/analysis/README.md +0 -9
- package/.claude/commands/automation/README.md +0 -9
- package/.claude/commands/github/README.md +0 -11
- package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
- package/.claude/commands/hooks/README.md +0 -11
- package/.claude/commands/monitoring/README.md +0 -9
- package/.claude/commands/optimization/README.md +0 -9
- package/.claude/commands/training/README.md +0 -9
- package/.claude/commands/workflows/README.md +0 -9
- package/.claude/config.json +0 -36
- package/.claude/helpers/github-setup.sh +0 -28
- package/.claude/helpers/quick-start.sh +0 -19
- package/.claude/helpers/setup-mcp.sh +0 -18
- package/.claude/settings.json +0 -114
- package/.claude/settings.local.json +0 -33
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -9
- package/.claude-flow/metrics/system-metrics.json +0 -15986
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.roo/README.md +0 -402
- package/.roo/mcp-list.txt +0 -257
- package/.roo/mcp.json +0 -32
- package/.roo/workflows/basic-tdd.json +0 -32
- package/.roomodes +0 -201
- package/CLAUDE.md +0 -393
- package/bin/snow-flow.js +0 -3
- package/dist/cli.js.bak +0 -2052
- package/dist/config/snow-flow-config.d.ts +0 -1492
- package/dist/config/snow-flow-config.js +0 -938
- package/scripts/create-env.js +0 -91
- package/scripts/postinstall.js +0 -30
- package/scripts/register-mcp-servers.js +0 -210
- package/scripts/reset-mcp-servers.js +0 -246
- package/scripts/setup-mcp.js +0 -106
- package/scripts/update-version.js +0 -31
- package/src/agents/README.md +0 -192
- package/src/agents/base-agent.ts +0 -251
- package/src/agents/coordinator.ts +0 -971
- package/src/agents/index.ts +0 -18
- package/src/agents/queen-403-handler.ts +0 -230
- package/src/agents/queen-agent.ts +0 -1399
- package/src/agents/script-writer-agent.ts +0 -769
- package/src/agents/security-agent.ts +0 -726
- package/src/agents/widget-creator-agent.ts +0 -568
- package/src/api/error-handling.ts +0 -1758
- package/src/api/natural-language-mapper.ts +0 -630
- package/src/api/performance-optimizer.ts +0 -891
- package/src/api/transaction-manager.ts +0 -754
- package/src/cli/deploy-artifact.ts +0 -304
- package/src/cli/snow-flow-cli-integration.ts +0 -434
- package/src/cli.ts +0 -4455
- package/src/cli.ts.bak +0 -5616
- package/src/compliance/advanced-compliance-system.ts +0 -1268
- package/src/compliance/index.ts +0 -19
- package/src/config/snow-flow-config.ts +0 -1019
- package/src/documentation/index.ts +0 -16
- package/src/documentation/self-documenting-system.ts +0 -1421
- package/src/dynamic-version.ts +0 -44
- package/src/healing/index.ts +0 -20
- package/src/healing/self-healing-system.ts +0 -1435
- package/src/health/README.md +0 -161
- package/src/health/system-health.ts +0 -995
- package/src/index.ts +0 -60
- package/src/intelligence/acl-analyzer.ts +0 -377
- package/src/intelligence/auto-resolution-engine.ts +0 -643
- package/src/intelligence/gap-analysis-engine.ts +0 -488
- package/src/intelligence/manual-instructions-generator.ts +0 -744
- package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
- package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
- package/src/intelligence/performance-recommendations-engine.ts +0 -1223
- package/src/intelligence/requirements-analyzer.ts +0 -1148
- package/src/intelligence/task-analyzer.ts +0 -628
- package/src/managers/scope-manager.ts +0 -555
- package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
- package/src/mcp/base-mcp-server.ts +0 -660
- package/src/mcp/http-transport-wrapper.ts +0 -426
- package/src/mcp/service-discovery-client.ts +0 -312
- package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
- package/src/mcp/servicenow-automation-mcp.ts +0 -838
- package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
- package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
- package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
- package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
- package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
- package/src/mcp/servicenow-integration-mcp.ts +0 -819
- package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
- package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
- package/src/mcp/servicenow-mcp-server.ts +0 -728
- package/src/mcp/servicenow-memory-mcp.ts +0 -474
- package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
- package/src/mcp/servicenow-operations-mcp.ts +0 -3384
- package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
- package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
- package/src/mcp/servicenow-progressive-indexer.ts +0 -370
- package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
- package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
- package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
- package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
- package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
- package/src/mcp/servicenow-update-set-mcp.ts +0 -811
- package/src/mcp/shared/agent-context-provider.ts +0 -365
- package/src/mcp/shared/base-mcp-server.ts +0 -2463
- package/src/mcp/shared/mcp-memory-manager.ts +0 -540
- package/src/mcp/shared/mcp-resource-manager.ts +0 -367
- package/src/mcp/snow-flow-mcp.ts +0 -911
- package/src/mcp/start-all-mcp-servers.ts +0 -102
- package/src/mcp/start-servicenow-mcp.ts +0 -67
- package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
- package/src/monitoring/performance-tracker.ts +0 -777
- package/src/optimization/cost-optimization-engine.ts +0 -1125
- package/src/optimization/index.ts +0 -10
- package/src/queen/README.md +0 -403
- package/src/queen/agent-factory.ts +0 -574
- package/src/queen/index.ts +0 -94
- package/src/queen/mcp-execution-bridge.ts +0 -681
- package/src/queen/neural-learning.ts +0 -319
- package/src/queen/parallel-agent-engine.ts +0 -848
- package/src/queen/queen-memory-system.ts +0 -490
- package/src/queen/queen-memory.ts +0 -456
- package/src/queen/servicenow-queen.ts +0 -1029
- package/src/queen/types.ts +0 -87
- package/src/rollback/smart-rollback-system.ts +0 -866
- package/src/schemas/deployment.schema.json +0 -58
- package/src/schemas/flow.schema.json +0 -79
- package/src/schemas/widget.schema.json +0 -72
- package/src/snow-flow-system.ts +0 -541
- package/src/sparc/sparc-help.ts +0 -49
- package/src/sparc/team-sparc.ts +0 -88
- package/src/strategies/global-scope-strategy.ts +0 -736
- package/src/templates/base/application.template.json +0 -45
- package/src/templates/base/business_rule.template.json +0 -33
- package/src/templates/base/script_include.template.json +0 -18
- package/src/templates/base/table.template.json +0 -64
- package/src/templates/base/widget.template.json +0 -25
- package/src/templates/patterns/composite.incident-management.template.json +0 -140
- package/src/templates/patterns/widget.dashboard.template.json +0 -238
- package/src/templates/patterns/widget.datatable.template.json +0 -292
- package/src/testing/integration-test-suite.ts +0 -1276
- package/src/types/index.ts +0 -183
- package/src/types/neo4j-driver.d.ts +0 -23
- package/src/types/servicenow.types.ts +0 -307
- package/src/types/snow-flow.types.ts +0 -186
- package/src/types/todo.types.ts +0 -70
- package/src/utils/action-type-cache.ts +0 -286
- package/src/utils/agent-detector.ts +0 -573
- package/src/utils/artifact-tracker.ts +0 -379
- package/src/utils/dependency-detector.ts +0 -233
- package/src/utils/deployment-metadata-handler.ts +0 -518
- package/src/utils/error-recovery.ts +0 -680
- package/src/utils/logger.ts +0 -60
- package/src/utils/mcp-auth-middleware.ts +0 -262
- package/src/utils/mcp-config-manager.ts +0 -270
- package/src/utils/mcp-server-manager.ts +0 -446
- package/src/utils/mcp-tool-registry.ts +0 -298
- package/src/utils/migrate-snow-flow.ts +0 -98
- package/src/utils/oauth-html-templates.ts +0 -188
- package/src/utils/scope-utils.ts +0 -443
- package/src/utils/servicenow-client.ts +0 -3321
- package/src/utils/servicenow-id-generator.ts +0 -181
- package/src/utils/snow-memory-manager.ts +0 -605
- package/src/utils/snow-oauth.ts +0 -797
- package/src/utils/template-engine.ts +0 -463
- package/src/utils/theme-manager.ts +0 -295
- package/src/utils/unified-auth-store.ts +0 -222
- package/src/utils/update-set-importer.ts +0 -422
- package/src/utils/update-set-xml-packager.ts +0 -371
- package/src/utils/widget-template-generator.ts +0 -1744
- package/src/version.ts +0 -1950
package/src/index.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snow-Flow: ServiceNow Hive-Mind Intelligence Framework
|
|
3
|
-
* Built with Claude Code integration
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Export main types
|
|
7
|
-
export * from './types/index.js';
|
|
8
|
-
|
|
9
|
-
// Export utilities
|
|
10
|
-
export { ServiceNowOAuth } from './utils/snow-oauth.js';
|
|
11
|
-
export { ServiceNowClient } from './utils/servicenow-client.js';
|
|
12
|
-
export { Logger } from './utils/logger.js';
|
|
13
|
-
|
|
14
|
-
// Export MCP server
|
|
15
|
-
export { ServiceNowMCPServer } from './mcp/servicenow-mcp-server.js';
|
|
16
|
-
|
|
17
|
-
// Snow-Flow System Integration (New)
|
|
18
|
-
export { SnowFlowSystem, snowFlowSystem } from './snow-flow-system.js';
|
|
19
|
-
export { SnowFlowConfig, snowFlowConfig } from './config/snow-flow-config.js';
|
|
20
|
-
export { MemorySystem } from './memory/memory-system.js';
|
|
21
|
-
export { ErrorRecovery, FALLBACK_STRATEGIES } from './utils/error-recovery.js';
|
|
22
|
-
export { PerformanceTracker } from './monitoring/performance-tracker.js';
|
|
23
|
-
export { SystemHealth } from './health/system-health.js';
|
|
24
|
-
|
|
25
|
-
// Re-export integration types
|
|
26
|
-
export type {
|
|
27
|
-
SwarmSession,
|
|
28
|
-
AgentInfo,
|
|
29
|
-
SwarmOptions,
|
|
30
|
-
SwarmResult,
|
|
31
|
-
SystemStatus
|
|
32
|
-
} from './snow-flow-system.js';
|
|
33
|
-
|
|
34
|
-
export type {
|
|
35
|
-
ISnowFlowConfig
|
|
36
|
-
} from './config/snow-flow-config.js';
|
|
37
|
-
|
|
38
|
-
export type {
|
|
39
|
-
ErrorContext,
|
|
40
|
-
RecoveryStrategy,
|
|
41
|
-
RecoveryResult,
|
|
42
|
-
ErrorMetrics
|
|
43
|
-
} from './utils/error-recovery.js';
|
|
44
|
-
|
|
45
|
-
export type {
|
|
46
|
-
PerformanceMetric,
|
|
47
|
-
AggregateMetrics,
|
|
48
|
-
SessionMetrics,
|
|
49
|
-
PerformanceReport,
|
|
50
|
-
Bottleneck
|
|
51
|
-
} from './monitoring/performance-tracker.js';
|
|
52
|
-
|
|
53
|
-
export type {
|
|
54
|
-
HealthCheckResult,
|
|
55
|
-
SystemHealthStatus,
|
|
56
|
-
SystemResources,
|
|
57
|
-
HealthThresholds
|
|
58
|
-
} from './health/system-health.js';
|
|
59
|
-
|
|
60
|
-
console.log('Snow-Flow: ServiceNow Hive-Mind Intelligence Framework loaded');
|
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ACL Analyzer for ServiceNow
|
|
3
|
-
* Automatically analyzes and suggests fixes for permission issues
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Logger } from '../utils/logger';
|
|
7
|
-
import { ServiceNowClient } from '../utils/servicenow-client';
|
|
8
|
-
|
|
9
|
-
export interface ACLAnalysisResult {
|
|
10
|
-
tableName: string;
|
|
11
|
-
operation: string;
|
|
12
|
-
hasAccess: boolean;
|
|
13
|
-
deniedBy: ACLRule[];
|
|
14
|
-
allowedBy: ACLRule[];
|
|
15
|
-
suggestions: ACLSuggestion[];
|
|
16
|
-
autoFixable: boolean;
|
|
17
|
-
manualSteps?: string[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ACLRule {
|
|
21
|
-
sys_id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
operation: string;
|
|
24
|
-
type: string;
|
|
25
|
-
admin_overrides: boolean;
|
|
26
|
-
active: boolean;
|
|
27
|
-
roles: string[];
|
|
28
|
-
condition: string;
|
|
29
|
-
script: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface ACLSuggestion {
|
|
33
|
-
type: 'add_role' | 'modify_acl' | 'create_acl' | 'system_property' | 'oauth_scope';
|
|
34
|
-
description: string;
|
|
35
|
-
risk: 'low' | 'medium' | 'high';
|
|
36
|
-
autoApplicable: boolean;
|
|
37
|
-
implementation?: () => Promise<boolean>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class ACLAnalyzer {
|
|
41
|
-
private logger: Logger;
|
|
42
|
-
private client: ServiceNowClient;
|
|
43
|
-
|
|
44
|
-
constructor(client: ServiceNowClient, logger: Logger) {
|
|
45
|
-
this.client = client;
|
|
46
|
-
this.logger = logger;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Analyze ACLs for a specific table and operation
|
|
51
|
-
*/
|
|
52
|
-
async analyzeTableAccess(
|
|
53
|
-
tableName: string,
|
|
54
|
-
operation: 'read' | 'write' | 'create' | 'delete' = 'write'
|
|
55
|
-
): Promise<ACLAnalysisResult> {
|
|
56
|
-
this.logger.info(`Analyzing ACLs for ${tableName}.${operation}`);
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
// 1. Get current user info
|
|
60
|
-
const userInfo = await this.getCurrentUserInfo();
|
|
61
|
-
|
|
62
|
-
// 2. Get all ACLs for the table
|
|
63
|
-
const acls = await this.getTableACLs(tableName, operation);
|
|
64
|
-
|
|
65
|
-
// 3. Evaluate which ACLs allow/deny access
|
|
66
|
-
const evaluation = await this.evaluateACLs(acls, userInfo);
|
|
67
|
-
|
|
68
|
-
// 4. Generate suggestions for fixing access
|
|
69
|
-
const suggestions = await this.generateSuggestions(
|
|
70
|
-
tableName,
|
|
71
|
-
operation,
|
|
72
|
-
evaluation,
|
|
73
|
-
userInfo
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
tableName,
|
|
78
|
-
operation,
|
|
79
|
-
hasAccess: evaluation.allowed.length > 0 && evaluation.denied.length === 0,
|
|
80
|
-
deniedBy: evaluation.denied,
|
|
81
|
-
allowedBy: evaluation.allowed,
|
|
82
|
-
suggestions,
|
|
83
|
-
autoFixable: suggestions.some(s => s.autoApplicable),
|
|
84
|
-
manualSteps: this.generateManualSteps(tableName, operation, suggestions)
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
} catch (error) {
|
|
88
|
-
this.logger.error('ACL _analysis failed:', error);
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Get current user information including roles
|
|
95
|
-
*/
|
|
96
|
-
private async getCurrentUserInfo(): Promise<any> {
|
|
97
|
-
try {
|
|
98
|
-
// Get current user
|
|
99
|
-
const userResponse = await this.client.makeRequest('/api/now/ui/user/current');
|
|
100
|
-
if (!userResponse.success) {
|
|
101
|
-
throw new Error('Failed to get current user info');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const userId = userResponse.data.result.sys_id;
|
|
105
|
-
|
|
106
|
-
// Get user roles
|
|
107
|
-
const rolesResponse = await this.client.searchRecords(
|
|
108
|
-
'sys_user_has_role',
|
|
109
|
-
`user=${userId}^role.active=true`,
|
|
110
|
-
100
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const roles = rolesResponse.success && rolesResponse.data ?
|
|
114
|
-
rolesResponse.data.map((r: any) => r.role.name) : [];
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
...userResponse.data.result,
|
|
118
|
-
roles
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
} catch (error) {
|
|
122
|
-
this.logger.error('Failed to get user info:', error);
|
|
123
|
-
return { roles: [] };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Get all ACLs for a specific table and operation
|
|
129
|
-
*/
|
|
130
|
-
private async getTableACLs(tableName: string, operation: string): Promise<ACLRule[]> {
|
|
131
|
-
try {
|
|
132
|
-
// Search for ACLs on this table
|
|
133
|
-
const query = `name=${tableName}^operation=${operation}^ORoperation=*^active=true`;
|
|
134
|
-
|
|
135
|
-
const response = await this.client.searchRecords('sys_security_acl', query, 100);
|
|
136
|
-
|
|
137
|
-
if (!response.success || !response.data) {
|
|
138
|
-
this.logger.warn(`No ACLs found for ${tableName}.${operation}`);
|
|
139
|
-
return [];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return response.data.map((acl: any) => ({
|
|
143
|
-
sys_id: acl.sys_id,
|
|
144
|
-
name: acl.name,
|
|
145
|
-
operation: acl.operation,
|
|
146
|
-
type: acl.type,
|
|
147
|
-
admin_overrides: acl.admin_overrides === 'true',
|
|
148
|
-
active: acl.active === 'true',
|
|
149
|
-
roles: this.parseRoles(acl.roles),
|
|
150
|
-
condition: acl.condition || '',
|
|
151
|
-
script: acl.script || ''
|
|
152
|
-
}));
|
|
153
|
-
|
|
154
|
-
} catch (error) {
|
|
155
|
-
this.logger.error('Failed to fetch ACLs:', error);
|
|
156
|
-
return [];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Parse roles from ACL role field
|
|
162
|
-
*/
|
|
163
|
-
private parseRoles(roleField: string): string[] {
|
|
164
|
-
if (!roleField) return [];
|
|
165
|
-
return roleField.split(',').map(r => r.trim()).filter(r => r);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Evaluate which ACLs allow or deny access
|
|
170
|
-
*/
|
|
171
|
-
private async evaluateACLs(
|
|
172
|
-
acls: ACLRule[],
|
|
173
|
-
userInfo: any
|
|
174
|
-
): Promise<{ allowed: ACLRule[], denied: ACLRule[] }> {
|
|
175
|
-
const allowed: ACLRule[] = [];
|
|
176
|
-
const denied: ACLRule[] = [];
|
|
177
|
-
|
|
178
|
-
for (const acl of acls) {
|
|
179
|
-
// Check if user has admin role and admin_overrides is true
|
|
180
|
-
if (acl.admin_overrides && userInfo.roles.includes('admin')) {
|
|
181
|
-
allowed.push(acl);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Check if user has any of the required roles
|
|
186
|
-
const hasRequiredRole = acl.roles.length === 0 ||
|
|
187
|
-
acl.roles.some(role => userInfo.roles.includes(role));
|
|
188
|
-
|
|
189
|
-
if (hasRequiredRole) {
|
|
190
|
-
// If there's a condition or script, we can't evaluate it here
|
|
191
|
-
// Assume it passes for now
|
|
192
|
-
if (acl.condition || acl.script) {
|
|
193
|
-
this.logger.warn(`ACL ${acl.sys_id} has condition/script - assuming pass`);
|
|
194
|
-
}
|
|
195
|
-
allowed.push(acl);
|
|
196
|
-
} else {
|
|
197
|
-
denied.push(acl);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return { allowed, denied };
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Generate suggestions for fixing access issues
|
|
206
|
-
*/
|
|
207
|
-
private async generateSuggestions(
|
|
208
|
-
tableName: string,
|
|
209
|
-
operation: string,
|
|
210
|
-
evaluation: { allowed: ACLRule[], denied: ACLRule[] },
|
|
211
|
-
userInfo: any
|
|
212
|
-
): Promise<ACLSuggestion[]> {
|
|
213
|
-
const suggestions: ACLSuggestion[] = [];
|
|
214
|
-
|
|
215
|
-
// If denied by ACLs, suggest role additions
|
|
216
|
-
if (evaluation.denied.length > 0) {
|
|
217
|
-
const missingRoles = new Set<string>();
|
|
218
|
-
|
|
219
|
-
evaluation.denied.forEach(acl => {
|
|
220
|
-
acl.roles.forEach(role => {
|
|
221
|
-
if (!userInfo.roles.includes(role)) {
|
|
222
|
-
missingRoles.add(role);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Suggest adding specific roles
|
|
228
|
-
for (const role of missingRoles) {
|
|
229
|
-
if (this.isSafeRole(role)) {
|
|
230
|
-
suggestions.push({
|
|
231
|
-
type: 'add_role',
|
|
232
|
-
description: `Add role '${role}' to your user account`,
|
|
233
|
-
risk: this.getRoleRisk(role),
|
|
234
|
-
autoApplicable: false // Roles usually can't be auto-added
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// For sp_widget specifically, check system properties
|
|
241
|
-
if (tableName === 'sp_widget') {
|
|
242
|
-
suggestions.push({
|
|
243
|
-
type: 'system_property',
|
|
244
|
-
description: 'Enable Service Portal API access via system property',
|
|
245
|
-
risk: 'low',
|
|
246
|
-
autoApplicable: true,
|
|
247
|
-
implementation: async () => {
|
|
248
|
-
return await this.enableServicePortalAPIAccess();
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
suggestions.push({
|
|
253
|
-
type: 'oauth_scope',
|
|
254
|
-
description: 'Update OAuth application to allow cross-scope access',
|
|
255
|
-
risk: 'medium',
|
|
256
|
-
autoApplicable: false
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// If no ACLs exist, suggest creating one
|
|
261
|
-
if (evaluation.allowed.length === 0 && evaluation.denied.length === 0) {
|
|
262
|
-
suggestions.push({
|
|
263
|
-
type: 'create_acl',
|
|
264
|
-
description: `Create ACL for ${tableName}.${operation} with appropriate roles`,
|
|
265
|
-
risk: 'high',
|
|
266
|
-
autoApplicable: false
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return suggestions;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Check if a role is safe to suggest
|
|
275
|
-
*/
|
|
276
|
-
private isSafeRole(role: string): boolean {
|
|
277
|
-
const unsafeRoles = ['security_admin', 'maint'];
|
|
278
|
-
return !unsafeRoles.includes(role);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Get risk level for a role
|
|
283
|
-
*/
|
|
284
|
-
private getRoleRisk(role: string): 'low' | 'medium' | 'high' {
|
|
285
|
-
const highRiskRoles = ['admin', 'security_admin'];
|
|
286
|
-
const mediumRiskRoles = ['sp_admin', 'app_creator'];
|
|
287
|
-
|
|
288
|
-
if (highRiskRoles.includes(role)) return 'high';
|
|
289
|
-
if (mediumRiskRoles.includes(role)) return 'medium';
|
|
290
|
-
return 'low';
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Try to enable Service Portal API access
|
|
295
|
-
*/
|
|
296
|
-
private async enableServicePortalAPIAccess(): Promise<boolean> {
|
|
297
|
-
try {
|
|
298
|
-
const propertyUpdate = await this.client.updateRecord(
|
|
299
|
-
'sys_properties',
|
|
300
|
-
'glide.service_portal.enable_api_access',
|
|
301
|
-
{ value: 'true' }
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
return propertyUpdate.success;
|
|
305
|
-
} catch (error) {
|
|
306
|
-
this.logger.error('Failed to enable SP API access:', error);
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Generate manual steps for fixing access
|
|
313
|
-
*/
|
|
314
|
-
private generateManualSteps(
|
|
315
|
-
tableName: string,
|
|
316
|
-
operation: string,
|
|
317
|
-
suggestions: ACLSuggestion[]
|
|
318
|
-
): string[] {
|
|
319
|
-
const steps: string[] = [];
|
|
320
|
-
|
|
321
|
-
steps.push(`1. Navigate to System Security > Access Control (ACL)`);
|
|
322
|
-
steps.push(`2. Search for ACLs where Name = '${tableName}' and Operation = '${operation}'`);
|
|
323
|
-
steps.push(`3. Review the roles required by each ACL`);
|
|
324
|
-
|
|
325
|
-
if (suggestions.some(s => s.type === 'add_role')) {
|
|
326
|
-
steps.push(`4. To add roles to your user:`);
|
|
327
|
-
steps.push(` - Navigate to User Administration > Users`);
|
|
328
|
-
steps.push(` - Find your user record`);
|
|
329
|
-
steps.push(` - Use the Roles related list to add required roles`);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (tableName === 'sp_widget') {
|
|
333
|
-
steps.push(`5. For Service Portal widgets:`);
|
|
334
|
-
steps.push(` - Check System Properties > Service Portal`);
|
|
335
|
-
steps.push(` - Ensure 'glide.service_portal.enable_api_access' is true`);
|
|
336
|
-
steps.push(` - Check OAuth application has 'All application scopes' access`);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return steps;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Attempt automatic fixes for permission issues
|
|
344
|
-
*/
|
|
345
|
-
async attemptAutoFix(_analysis: ACLAnalysisResult): Promise<{
|
|
346
|
-
fixed: boolean;
|
|
347
|
-
appliedFixes: string[];
|
|
348
|
-
failedFixes: string[];
|
|
349
|
-
}> {
|
|
350
|
-
const appliedFixes: string[] = [];
|
|
351
|
-
const failedFixes: string[] = [];
|
|
352
|
-
|
|
353
|
-
for (const suggestion of _analysis.suggestions) {
|
|
354
|
-
if (suggestion.autoApplicable && suggestion.implementation) {
|
|
355
|
-
try {
|
|
356
|
-
this.logger.info(`Attempting auto-fix: ${suggestion.description}`);
|
|
357
|
-
const success = await suggestion.implementation();
|
|
358
|
-
|
|
359
|
-
if (success) {
|
|
360
|
-
appliedFixes.push(suggestion.description);
|
|
361
|
-
} else {
|
|
362
|
-
failedFixes.push(suggestion.description);
|
|
363
|
-
}
|
|
364
|
-
} catch (error) {
|
|
365
|
-
this.logger.error(`Auto-fix failed: ${suggestion.description}`, error);
|
|
366
|
-
failedFixes.push(suggestion.description);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
return {
|
|
372
|
-
fixed: appliedFixes.length > 0 && failedFixes.length === 0,
|
|
373
|
-
appliedFixes,
|
|
374
|
-
failedFixes
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
}
|