timonel 3.0.0 → 3.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +431 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/lib/policy/configurationLoader.d.ts +46 -0
- package/dist/lib/policy/configurationLoader.js +251 -0
- package/dist/lib/policy/errorContextGenerator.d.ts +63 -0
- package/dist/lib/policy/errorContextGenerator.js +302 -0
- package/dist/lib/policy/errors.d.ts +40 -0
- package/dist/lib/policy/errors.js +109 -0
- package/dist/lib/policy/index.d.ts +11 -0
- package/dist/lib/policy/index.js +10 -0
- package/dist/lib/policy/parallelExecutor.d.ts +58 -0
- package/dist/lib/policy/parallelExecutor.js +215 -0
- package/dist/lib/policy/pluginLoader.d.ts +41 -0
- package/dist/lib/policy/pluginLoader.js +220 -0
- package/dist/lib/policy/pluginRegistry.d.ts +14 -0
- package/dist/lib/policy/pluginRegistry.js +69 -0
- package/dist/lib/policy/policyEngine.d.ts +39 -0
- package/dist/lib/policy/policyEngine.js +495 -0
- package/dist/lib/policy/resultAggregator.d.ts +8 -0
- package/dist/lib/policy/resultAggregator.js +138 -0
- package/dist/lib/policy/resultFormatter.d.ts +25 -0
- package/dist/lib/policy/resultFormatter.js +217 -0
- package/dist/lib/policy/types.d.ts +111 -0
- package/dist/lib/policy/types.js +1 -0
- package/dist/lib/policy/validationCache.d.ts +58 -0
- package/dist/lib/policy/validationCache.js +289 -0
- package/dist/lib/rutter.d.ts +7 -2
- package/dist/lib/rutter.js +177 -8
- package/dist/lib/templates/flexible-subchart.js +4 -2
- package/dist/lib/templates/umbrella-chart.js +8 -8
- package/dist/lib/umbrellaRutter.d.ts +1 -1
- package/dist/lib/umbrellaRutter.js +2 -2
- package/dist/lib/validation/inputValidator.d.ts +26 -0
- package/dist/lib/validation/inputValidator.js +176 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/index.js +1 -0
- package/package.json +21 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# [3.1.0-beta.1](https://github.com/KenkoGeek/timonel/compare/v3.0.0...v3.1.0-beta.1) (2026-01-03)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- **core:** policy engine plugin and documentation improvement ([#250](https://github.com/KenkoGeek/timonel/issues/250)) ([400478e](https://github.com/KenkoGeek/timonel/commit/400478e32a30f6f00864832347deb176cb81c94b))
|
|
6
|
+
|
|
1
7
|
# [3.0.0](https://github.com/KenkoGeek/timonel/compare/v2.13.0...v3.0.0) (2025-12-07)
|
|
2
8
|
|
|
3
9
|
- feat!: rename ChartFactory to Rutter (maritime pilot concept) ([b0a7a33](https://github.com/KenkoGeek/timonel/commit/b0a7a3361e761a5b20ff2c203d55bdfab35323af))
|
package/README.md
CHANGED
|
@@ -102,6 +102,11 @@ Useful string-based utilities (no ValuesRef equivalent):
|
|
|
102
102
|
- Command injection prevention (CWE-78/77/88)
|
|
103
103
|
- Log injection protection (CWE-117)
|
|
104
104
|
- Code injection prevention (CWE-94)
|
|
105
|
+
- **🔍 Policy Engine** (NEW):
|
|
106
|
+
- Extensible validation framework for Kubernetes manifests
|
|
107
|
+
- Plugin-based architecture for custom policy rules
|
|
108
|
+
- Zero-impact integration (completely optional)
|
|
109
|
+
- Support for security, compliance, and best practice policies
|
|
105
110
|
- **NetworkPolicy support** for pod-level network isolation
|
|
106
111
|
- **Helm chart validation** with `validateHelmYaml`
|
|
107
112
|
- **SecurityUtils** for path validation and sanitization
|
|
@@ -212,6 +217,64 @@ chart.addManifest(
|
|
|
212
217
|
chart.write('./dist');
|
|
213
218
|
```
|
|
214
219
|
|
|
220
|
+
### Policy Engine Integration
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { Rutter, PolicyEngine } from 'timonel';
|
|
224
|
+
import { securityPolicies } from '@mycompany/k8s-security-policies';
|
|
225
|
+
|
|
226
|
+
// Create policy engine with custom plugins
|
|
227
|
+
const policyEngine = new PolicyEngine().use(securityPolicies).configure({
|
|
228
|
+
timeout: 5000,
|
|
229
|
+
parallel: true,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const chart = new Rutter({
|
|
233
|
+
meta: {
|
|
234
|
+
name: 'secure-app',
|
|
235
|
+
version: '1.0.0',
|
|
236
|
+
},
|
|
237
|
+
// Optional policy validation
|
|
238
|
+
policyEngine,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Policies validate manifests before chart generation
|
|
242
|
+
chart.write('./dist'); // Fails if policy violations found
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Creating Custom Policy Plugins
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { PolicyPlugin, PolicyViolation } from 'timonel';
|
|
249
|
+
|
|
250
|
+
export const mySecurityPolicy: PolicyPlugin = {
|
|
251
|
+
name: 'my-security-policy',
|
|
252
|
+
version: '1.0.0',
|
|
253
|
+
description: 'Custom security validation rules',
|
|
254
|
+
|
|
255
|
+
async validate(manifests, context) {
|
|
256
|
+
const violations: PolicyViolation[] = [];
|
|
257
|
+
|
|
258
|
+
for (const manifest of manifests) {
|
|
259
|
+
if (manifest.kind === 'Deployment') {
|
|
260
|
+
// Check for security context
|
|
261
|
+
if (!manifest.spec?.template?.spec?.securityContext) {
|
|
262
|
+
violations.push({
|
|
263
|
+
plugin: this.name,
|
|
264
|
+
severity: 'error',
|
|
265
|
+
message: 'Deployment must specify securityContext',
|
|
266
|
+
resourcePath: `${manifest.kind}/${manifest.metadata?.name}`,
|
|
267
|
+
suggestion: 'Add spec.template.spec.securityContext to your Deployment',
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return violations;
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
```
|
|
277
|
+
|
|
215
278
|
### Umbrella Chart with Multiple Services
|
|
216
279
|
|
|
217
280
|
```typescript
|
|
@@ -350,12 +413,380 @@ with `v.if()`, `v.range()`, `v.with()`.
|
|
|
350
413
|
[Type-Safe Helm Helpers Guide](https://github.com/KenkoGeek/timonel/wiki/Helm-Helpers-System) for
|
|
351
414
|
complete documentation, examples, and best practices.
|
|
352
415
|
|
|
416
|
+
## 🔍 Policy Engine
|
|
417
|
+
|
|
418
|
+
The Policy Engine provides extensible validation for Kubernetes manifests through a
|
|
419
|
+
plugin-based architecture. It's completely optional and has zero impact on existing users.
|
|
420
|
+
|
|
421
|
+
### Key Features
|
|
422
|
+
|
|
423
|
+
- **🔌 Plugin Architecture**: Extensible through external npm packages
|
|
424
|
+
- **⚡ Zero Impact**: Completely optional with no performance overhead when unused
|
|
425
|
+
- **🛡️ Security Focus**: Built-in support for security and compliance policies
|
|
426
|
+
- **🔄 Async Support**: Handles both synchronous and asynchronous validation plugins
|
|
427
|
+
- **📊 Rich Reporting**: Detailed violation reports with suggestions and context
|
|
428
|
+
- **⏱️ Timeout Protection**: Configurable timeouts prevent hanging validations
|
|
429
|
+
- **🔧 Configurable**: Environment-specific policy configuration support
|
|
430
|
+
- **🚀 Performance Optimized**: Parallel execution, caching, and resource monitoring
|
|
431
|
+
- **🔄 Error Resilience**: Graceful degradation and retry mechanisms
|
|
432
|
+
- **📈 Observability**: Structured logging and performance metrics
|
|
433
|
+
|
|
434
|
+
### Quick Start
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
import { Rutter, PolicyEngine } from 'timonel';
|
|
438
|
+
|
|
439
|
+
// Optional: Add policy validation
|
|
440
|
+
const policyEngine = new PolicyEngine({
|
|
441
|
+
timeout: 10000,
|
|
442
|
+
parallel: true,
|
|
443
|
+
gracefulDegradation: true,
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// Register plugins
|
|
447
|
+
await policyEngine.use(await import('@mycompany/security-policies'));
|
|
448
|
+
await policyEngine.use(await import('@kubernetes/best-practices'));
|
|
449
|
+
|
|
450
|
+
const chart = new Rutter({
|
|
451
|
+
meta: { name: 'my-app', version: '1.0.0' },
|
|
452
|
+
policyEngine, // ← Completely optional
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
chart.write('./dist'); // Validates before writing
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Available Policy Plugins
|
|
459
|
+
|
|
460
|
+
**Built-in Examples:**
|
|
461
|
+
|
|
462
|
+
- **Security Plugin** - Comprehensive security validation (security contexts, RBAC, network policies)
|
|
463
|
+
- **Best Practices Plugin** - Kubernetes best practices (resource limits, naming, probes)
|
|
464
|
+
- **AWS Plugin** - AWS-specific validations (EKS, ALB, IRSA, cost optimization)
|
|
465
|
+
|
|
466
|
+
**Community Plugins:**
|
|
467
|
+
|
|
468
|
+
- `@kubernetes/pod-security-standards` - Official Kubernetes PSS validation
|
|
469
|
+
- `@open-policy-agent/timonel-plugin` - OPA Rego policy integration
|
|
470
|
+
- `@falco/security-policies` - Falco runtime security rules
|
|
471
|
+
|
|
472
|
+
**Enterprise Plugins:**
|
|
473
|
+
|
|
474
|
+
- `@company/compliance-policies` - Organization-specific compliance rules
|
|
475
|
+
- `@aws/well-architected-policies` - AWS Well-Architected Framework validation
|
|
476
|
+
- `@security/cis-benchmarks` - CIS Kubernetes Benchmark validation
|
|
477
|
+
|
|
478
|
+
### Creating Custom Policies
|
|
479
|
+
|
|
480
|
+
```typescript
|
|
481
|
+
import { PolicyPlugin, PolicyViolation, ValidationContext } from 'timonel';
|
|
482
|
+
|
|
483
|
+
export const customSecurityPolicy: PolicyPlugin = {
|
|
484
|
+
name: 'custom-security-policy',
|
|
485
|
+
version: '1.0.0',
|
|
486
|
+
description: 'Custom security validation rules',
|
|
487
|
+
|
|
488
|
+
// Optional: Configuration schema for validation
|
|
489
|
+
configSchema: {
|
|
490
|
+
type: 'object',
|
|
491
|
+
properties: {
|
|
492
|
+
strictMode: { type: 'boolean', default: false },
|
|
493
|
+
allowedNamespaces: { type: 'array', items: { type: 'string' } },
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
|
|
497
|
+
async validate(manifests: unknown[], context: ValidationContext): Promise<PolicyViolation[]> {
|
|
498
|
+
const violations: PolicyViolation[] = [];
|
|
499
|
+
const config = context.config as { strictMode?: boolean; allowedNamespaces?: string[] };
|
|
500
|
+
|
|
501
|
+
for (const manifest of manifests) {
|
|
502
|
+
if (manifest.kind === 'Deployment') {
|
|
503
|
+
// Validate security context
|
|
504
|
+
if (!manifest.spec?.template?.spec?.securityContext) {
|
|
505
|
+
violations.push({
|
|
506
|
+
plugin: this.name,
|
|
507
|
+
severity: config?.strictMode ? 'error' : 'warning',
|
|
508
|
+
message: 'Deployment should specify securityContext',
|
|
509
|
+
resourcePath: `${manifest.kind}/${manifest.metadata?.name}`,
|
|
510
|
+
field: 'spec.template.spec.securityContext',
|
|
511
|
+
suggestion: 'Add securityContext with runAsNonRoot: true',
|
|
512
|
+
context: {
|
|
513
|
+
kubernetesVersion: context.kubernetesVersion,
|
|
514
|
+
environment: context.environment,
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Validate namespace restrictions
|
|
520
|
+
const namespace = manifest.metadata?.namespace || 'default';
|
|
521
|
+
if (config?.allowedNamespaces && !config.allowedNamespaces.includes(namespace)) {
|
|
522
|
+
violations.push({
|
|
523
|
+
plugin: this.name,
|
|
524
|
+
severity: 'error',
|
|
525
|
+
message: `Deployment in unauthorized namespace: ${namespace}`,
|
|
526
|
+
resourcePath: `${manifest.kind}/${manifest.metadata?.name}`,
|
|
527
|
+
field: 'metadata.namespace',
|
|
528
|
+
suggestion: `Deploy to allowed namespaces: ${config.allowedNamespaces.join(', ')}`,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return violations;
|
|
535
|
+
},
|
|
536
|
+
};
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### Advanced Configuration
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
const policyEngine = new PolicyEngine({
|
|
543
|
+
// Execution settings
|
|
544
|
+
timeout: 15000, // 15 second timeout per plugin
|
|
545
|
+
parallel: true, // Run plugins in parallel for better performance
|
|
546
|
+
failFast: false, // Collect all violations before failing
|
|
547
|
+
gracefulDegradation: true, // Continue on plugin failures
|
|
548
|
+
|
|
549
|
+
// Performance optimization
|
|
550
|
+
cacheOptions: {
|
|
551
|
+
maxSize: 1000, // Cache up to 1000 validation results
|
|
552
|
+
ttl: 300000, // 5 minute cache TTL
|
|
553
|
+
enableStats: true, // Enable cache performance monitoring
|
|
554
|
+
},
|
|
555
|
+
|
|
556
|
+
// Parallel execution tuning
|
|
557
|
+
parallelOptions: {
|
|
558
|
+
maxConcurrency: 4, // Run up to 4 plugins concurrently
|
|
559
|
+
enableResourceMonitoring: true,
|
|
560
|
+
},
|
|
561
|
+
|
|
562
|
+
// Retry configuration
|
|
563
|
+
retryConfig: {
|
|
564
|
+
maxAttempts: 3,
|
|
565
|
+
baseDelay: 1000,
|
|
566
|
+
retryOnTimeout: true,
|
|
567
|
+
retryOnPluginError: false,
|
|
568
|
+
},
|
|
569
|
+
|
|
570
|
+
// Plugin-specific configuration
|
|
571
|
+
pluginConfig: {
|
|
572
|
+
'security-plugin': {
|
|
573
|
+
strictMode: true,
|
|
574
|
+
allowedNamespaces: ['default', 'kube-system'],
|
|
575
|
+
securityContext: {
|
|
576
|
+
required: true,
|
|
577
|
+
runAsNonRoot: true,
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
'best-practices-plugin': {
|
|
581
|
+
enforceResourceLimits: true,
|
|
582
|
+
requireLabels: ['app', 'version', 'environment'],
|
|
583
|
+
maxReplicas: 50,
|
|
584
|
+
},
|
|
585
|
+
'aws-plugin': {
|
|
586
|
+
region: 'us-west-2',
|
|
587
|
+
enforceTagging: true,
|
|
588
|
+
costOptimization: {
|
|
589
|
+
enabled: true,
|
|
590
|
+
maxInstanceSize: 'xlarge',
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
// Register plugins
|
|
597
|
+
await policyEngine.use(securityPolicies);
|
|
598
|
+
await policyEngine.use(bestPracticesPolicies);
|
|
599
|
+
await policyEngine.use(awsPolicies);
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Environment-Specific Policies
|
|
603
|
+
|
|
604
|
+
```typescript
|
|
605
|
+
// Load different policies based on environment
|
|
606
|
+
const createPolicyEngine = (environment: string) => {
|
|
607
|
+
const engine = new PolicyEngine({
|
|
608
|
+
environment,
|
|
609
|
+
configurationLoader: {
|
|
610
|
+
configurationFiles: ['config/policy-engine.json', `config/environments/${environment}.json`],
|
|
611
|
+
},
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
// Base security policies for all environments
|
|
615
|
+
await engine.use(baseSecurity);
|
|
616
|
+
|
|
617
|
+
// Environment-specific policies
|
|
618
|
+
switch (environment) {
|
|
619
|
+
case 'production':
|
|
620
|
+
await engine.use(strictSecurity);
|
|
621
|
+
await engine.use(compliancePolicies);
|
|
622
|
+
await engine.use(awsPolicies);
|
|
623
|
+
break;
|
|
624
|
+
case 'staging':
|
|
625
|
+
await engine.use(moderateSecurity);
|
|
626
|
+
await engine.use(awsPolicies);
|
|
627
|
+
break;
|
|
628
|
+
case 'development':
|
|
629
|
+
// Minimal policies for development
|
|
630
|
+
await engine.use(basicSecurity);
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return engine;
|
|
635
|
+
};
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### Integration with CI/CD
|
|
639
|
+
|
|
640
|
+
```typescript
|
|
641
|
+
// In your CI/CD pipeline
|
|
642
|
+
import { Rutter, PolicyEngine, PolicyEngineError } from 'timonel';
|
|
643
|
+
|
|
644
|
+
const validateChart = async (chartPath: string, environment: string) => {
|
|
645
|
+
const policyEngine = await createPolicyEngine(environment);
|
|
646
|
+
|
|
647
|
+
try {
|
|
648
|
+
const chart = new Rutter({
|
|
649
|
+
meta: { name: 'my-app', version: process.env.VERSION },
|
|
650
|
+
policyEngine,
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
await chart.write(chartPath);
|
|
654
|
+
|
|
655
|
+
// Log validation success with metrics
|
|
656
|
+
const stats = policyEngine.getCacheStats();
|
|
657
|
+
console.log('✅ Chart validation passed', {
|
|
658
|
+
environment,
|
|
659
|
+
cacheHitRate: stats.hitRate,
|
|
660
|
+
pluginCount: policyEngine.getPluginCount(),
|
|
661
|
+
});
|
|
662
|
+
} catch (error) {
|
|
663
|
+
if (error instanceof PolicyEngineError) {
|
|
664
|
+
console.error('❌ Policy violations found:');
|
|
665
|
+
|
|
666
|
+
// Group violations by severity
|
|
667
|
+
const errors = error.violations.filter((v) => v.severity === 'error');
|
|
668
|
+
const warnings = error.violations.filter((v) => v.severity === 'warning');
|
|
669
|
+
|
|
670
|
+
if (errors.length > 0) {
|
|
671
|
+
console.error(`\n🚨 Errors (${errors.length}):`);
|
|
672
|
+
errors.forEach((v) => {
|
|
673
|
+
console.error(` • ${v.resourcePath}: ${v.message}`);
|
|
674
|
+
if (v.suggestion) {
|
|
675
|
+
console.error(` 💡 ${v.suggestion}`);
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if (warnings.length > 0) {
|
|
681
|
+
console.warn(`\n⚠️ Warnings (${warnings.length}):`);
|
|
682
|
+
warnings.forEach((v) => {
|
|
683
|
+
console.warn(` • ${v.resourcePath}: ${v.message}`);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// Fail CI/CD on errors, but allow warnings
|
|
688
|
+
if (errors.length > 0) {
|
|
689
|
+
process.exit(1);
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
throw error;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
// Usage in GitHub Actions, GitLab CI, etc.
|
|
698
|
+
await validateChart('./dist', process.env.ENVIRONMENT || 'development');
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
### Plugin Ecosystem
|
|
702
|
+
|
|
703
|
+
The Policy Engine supports a rich ecosystem of plugins for various use cases:
|
|
704
|
+
|
|
705
|
+
#### Security & Compliance
|
|
706
|
+
|
|
707
|
+
- **Pod Security Standards** - Kubernetes PSS validation
|
|
708
|
+
- **CIS Benchmarks** - Center for Internet Security benchmarks
|
|
709
|
+
- **NIST Framework** - NIST Cybersecurity Framework compliance
|
|
710
|
+
- **PCI DSS** - Payment Card Industry compliance
|
|
711
|
+
- **SOC 2** - Service Organization Control 2 compliance
|
|
712
|
+
|
|
713
|
+
#### Cloud Provider Integrations
|
|
714
|
+
|
|
715
|
+
- **AWS Well-Architected** - AWS best practices and cost optimization
|
|
716
|
+
- **Azure Security Center** - Azure-specific security policies
|
|
717
|
+
- **GCP Security Command Center** - Google Cloud security validation
|
|
718
|
+
|
|
719
|
+
#### Development & Operations
|
|
720
|
+
|
|
721
|
+
- **GitOps Policies** - GitOps workflow validation
|
|
722
|
+
- **Resource Optimization** - Cost and performance optimization
|
|
723
|
+
- **Observability** - Monitoring and logging best practices
|
|
724
|
+
- **Backup & Recovery** - Data protection policies
|
|
725
|
+
|
|
726
|
+
#### Creating Plugin Packages
|
|
727
|
+
|
|
728
|
+
```typescript
|
|
729
|
+
// package.json for a policy plugin
|
|
730
|
+
{
|
|
731
|
+
"name": "@mycompany/k8s-security-policies",
|
|
732
|
+
"version": "1.0.0",
|
|
733
|
+
"description": "Security policies for Kubernetes manifests",
|
|
734
|
+
"main": "dist/index.js",
|
|
735
|
+
"types": "dist/index.d.ts",
|
|
736
|
+
"keywords": ["timonel", "policy", "security", "kubernetes"],
|
|
737
|
+
"peerDependencies": {
|
|
738
|
+
"timonel": "^3.0.0"
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// src/index.ts
|
|
743
|
+
export { SecurityPlugin } from './security-plugin.js';
|
|
744
|
+
export { CompliancePlugin } from './compliance-plugin.js';
|
|
745
|
+
export type { SecurityConfig, ComplianceConfig } from './types.js';
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
### Performance & Monitoring
|
|
749
|
+
|
|
750
|
+
The Policy Engine includes comprehensive performance monitoring:
|
|
751
|
+
|
|
752
|
+
```typescript
|
|
753
|
+
// Monitor policy engine performance
|
|
754
|
+
const result = await policyEngine.validate(manifests, { name: 'example-chart', version: '1.0.0' });
|
|
755
|
+
|
|
756
|
+
console.log('Validation Performance:', {
|
|
757
|
+
executionTime: result.metadata.executionTime,
|
|
758
|
+
pluginCount: result.metadata.pluginCount,
|
|
759
|
+
manifestCount: result.metadata.manifestCount,
|
|
760
|
+
violationsFound: result.violations.length,
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
// Cache performance monitoring
|
|
764
|
+
const cacheStats = policyEngine.getCacheStats();
|
|
765
|
+
console.log('Cache Performance:', {
|
|
766
|
+
hitRate: cacheStats.hitRate,
|
|
767
|
+
totalHits: cacheStats.hits,
|
|
768
|
+
totalMisses: cacheStats.misses,
|
|
769
|
+
cacheSize: cacheStats.size,
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
// Clear cache when needed
|
|
773
|
+
policyEngine.invalidateCache({ all: true });
|
|
774
|
+
```
|
|
775
|
+
|
|
353
776
|
## 📚 Documentation
|
|
354
777
|
|
|
355
778
|
- **[API Reference](https://github.com/KenkoGeek/timonel/wiki/API-Reference)** - Complete API
|
|
356
779
|
documentation
|
|
357
780
|
- **[CLI Reference](https://github.com/KenkoGeek/timonel/wiki/CLI-Reference)** - Command-line
|
|
358
781
|
interface guide
|
|
782
|
+
- **[Policy Engine Guide](https://github.com/KenkoGeek/timonel/wiki/Policy-Engine)** -
|
|
783
|
+
Policy validation and plugin development
|
|
784
|
+
- **[Plugin Development Guide](https://github.com/KenkoGeek/timonel/wiki/Plugin-Development)** -
|
|
785
|
+
Creating custom policy plugins
|
|
786
|
+
- **[Configuration Reference](https://github.com/KenkoGeek/timonel/wiki/Policy-Configuration)** -
|
|
787
|
+
Policy engine configuration options
|
|
788
|
+
- **[Policy Examples](https://github.com/KenkoGeek/timonel/wiki/Policy-Examples)** - Example plugins
|
|
789
|
+
and usage patterns
|
|
359
790
|
- **[Examples](https://github.com/KenkoGeek/timonel/wiki/Examples)** - Real-world usage examples
|
|
360
791
|
- **[Best Practices](https://github.com/KenkoGeek/timonel/wiki/Best-Practices)** - Recommended
|
|
361
792
|
patterns and practices
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ export * from './lib/helmChartWriter.js';
|
|
|
3
3
|
export * from './lib/rutter.js';
|
|
4
4
|
export * from './lib/security.js';
|
|
5
5
|
export * from './lib/umbrella.js';
|
|
6
|
+
export * from './lib/policy/index.js';
|
|
7
|
+
export * from './lib/validation/inputValidator.js';
|
|
6
8
|
export { FlexibleSubchart, createFlexibleSubchart } from './lib/templates/flexible-subchart.js';
|
|
7
9
|
export { UmbrellaChartTemplate as UmbrellaChart } from './lib/templates/umbrella-chart.js';
|
|
8
10
|
export type { ChartProps, SubchartProps } from './lib/types.js';
|
|
11
|
+
export type { PolicyConfig, PolicyRule, PolicyContext, PluginConfig } from './types/index.js';
|
|
9
12
|
export type { AWSALBIngressSpec, AWSEBSStorageClassSpec, AWSEFSStorageClassSpec, AWSIRSAServiceAccountSpec, } from './lib/resources/cloud/aws/awsResources.js';
|
|
10
13
|
export type { KarpenterDisruption, KarpenterDisruptionBudget, KarpenterEC2NodeClassSpec, KarpenterNodeClaimSpec, KarpenterNodePoolSpec, } from './lib/resources/cloud/aws/karpenterResources.js';
|
|
11
14
|
export { DEFAULT_TERMINATION_GRACE_PERIOD, isValidDisruptionBudget, isValidKubernetesDuration, KarpenterVersionUtils, } from './lib/resources/cloud/aws/karpenterResources.js';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export * from './lib/helmChartWriter.js';
|
|
|
3
3
|
export * from './lib/rutter.js';
|
|
4
4
|
export * from './lib/security.js';
|
|
5
5
|
export * from './lib/umbrella.js';
|
|
6
|
+
export * from './lib/policy/index.js';
|
|
7
|
+
export * from './lib/validation/inputValidator.js';
|
|
6
8
|
export { FlexibleSubchart, createFlexibleSubchart } from './lib/templates/flexible-subchart.js';
|
|
7
9
|
export { UmbrellaChartTemplate as UmbrellaChart } from './lib/templates/umbrella-chart.js';
|
|
8
10
|
export { DEFAULT_TERMINATION_GRACE_PERIOD, isValidDisruptionBudget, isValidKubernetesDuration, KarpenterVersionUtils, } from './lib/resources/cloud/aws/karpenterResources.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { JSONSchema, PolicyPlugin, ConfigurationLoaderOptions } from './types.js';
|
|
2
|
+
export type ConfigurationSource = 'environment' | 'file' | 'inline' | 'default';
|
|
3
|
+
export interface ConfigurationEntry {
|
|
4
|
+
readonly value: unknown;
|
|
5
|
+
readonly source: ConfigurationSource;
|
|
6
|
+
readonly environment?: string;
|
|
7
|
+
readonly priority: number;
|
|
8
|
+
readonly schema?: JSONSchema;
|
|
9
|
+
}
|
|
10
|
+
export interface PluginConfiguration {
|
|
11
|
+
readonly pluginName: string;
|
|
12
|
+
readonly config: Record<string, unknown>;
|
|
13
|
+
readonly entries: ConfigurationEntry[];
|
|
14
|
+
readonly validated: boolean;
|
|
15
|
+
readonly validationErrors?: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface EnvironmentConfiguration {
|
|
18
|
+
readonly environment: string;
|
|
19
|
+
readonly plugins: Record<string, unknown>;
|
|
20
|
+
readonly global?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export declare class ConfigurationLoader {
|
|
23
|
+
private readonly options;
|
|
24
|
+
private readonly logger;
|
|
25
|
+
private readonly configurations;
|
|
26
|
+
private readonly environmentConfigs;
|
|
27
|
+
constructor(options?: ConfigurationLoaderOptions);
|
|
28
|
+
loadPluginConfiguration(plugin: PolicyPlugin, environment?: string, inlineConfig?: Record<string, unknown>): Promise<PluginConfiguration>;
|
|
29
|
+
private collectConfigurationEntries;
|
|
30
|
+
private validatePluginConfiguration;
|
|
31
|
+
loadEnvironmentConfiguration(environment: string): Promise<EnvironmentConfiguration | undefined>;
|
|
32
|
+
validateConfiguration(config: Record<string, unknown>, schema: JSONSchema, pluginName: string): void;
|
|
33
|
+
addConfigurationEntry(pluginName: string, entry: ConfigurationEntry): void;
|
|
34
|
+
getConfigurationEntries(pluginName: string): ConfigurationEntry[];
|
|
35
|
+
clearCache(): void;
|
|
36
|
+
private loadFileConfiguration;
|
|
37
|
+
private loadEnvironmentVariableConfiguration;
|
|
38
|
+
private loadEnvironmentFromFiles;
|
|
39
|
+
private mergeConfigurations;
|
|
40
|
+
private parseEnvironmentValue;
|
|
41
|
+
private validateAgainstSchema;
|
|
42
|
+
private validateBasicType;
|
|
43
|
+
private validateObjectProperties;
|
|
44
|
+
private validateRequiredProperties;
|
|
45
|
+
private validateEachProperty;
|
|
46
|
+
}
|