Self-learning is excluded from the community edition (ADR-0004); the project owner reworks it separately. Cost tracking stays. - agent: delete behaviour evolution (evolve-schema, iterative GEPA, compose-evolution, evolution gates, orchestrator and deploy), improvement and correction detection, AgentLearning, the eval-dataset builder, optimization-capture and the agent_insights tool. Secret detection moves from eval-dataset to secret-patterns. The LLM wiring keeps only the Haiku adapter and judge call used by skill audit and hygiene, so @ax-llm/ax is now declared by agent instead of server. - server: delete /api/evolution/*, the evolution and optimizer services, GEPA expansion of the first chat message, the prompt_optimization and monthly_assessment jobs, the idle-session reviewer and its session-reviewer persona, prompt injection of past corrections and thumbs-down recorded as correction signals. Existing job rows of the removed types are ignored, not deleted. - core: delete OptimizationLogStore; stop re-exporting the improvement signal and evolution run stores. - web: delete the Evolution screen and the two job types in the automation editor. - delete packages/optimizer. Also logs UF-027 (self-learning loops read data nothing collects) and UF-028 (the Settings prompt-shape choice is ignored by chat).
78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { detectSecrets, redactSecrets, SECRET_PATTERN_NAMES } from '../src/secret-patterns.js';
|
|
|
|
describe('detectSecrets', () => {
|
|
it('returns null for clean text', () => {
|
|
expect(detectSecrets('Hello world, no secrets here.')).toBeNull();
|
|
expect(detectSecrets('pk_test_looks_partial')).toBeNull(); // too short
|
|
});
|
|
|
|
it('detects AWS access keys', () => {
|
|
expect(detectSecrets('AKIAIOSFODNN7EXAMPLE used for upload')).toBe('aws-access-key');
|
|
});
|
|
|
|
it('detects GitHub PATs', () => {
|
|
expect(detectSecrets('token=ghp_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789')).toBe('github-pat');
|
|
});
|
|
|
|
it('detects OpenAI keys', () => {
|
|
expect(detectSecrets('sk-proj-aaaaaaaaaaaaaaaaaaaaaaaa')).toBe('openai-key');
|
|
});
|
|
|
|
it('detects Anthropic keys', () => {
|
|
expect(detectSecrets('key = sk-ant-api03-aaaaaaaaaaaaaaaaaaa')).toBe('anthropic-key');
|
|
});
|
|
|
|
it('detects Google API keys', () => {
|
|
// Google API keys = literal "AIza" + exactly 35 chars
|
|
expect(detectSecrets('AIzaSyA0B1c2d3e4F5G6H7I8J9K0L1M2N3O4P5Q')).toBe('google-api-key');
|
|
});
|
|
|
|
it('detects Stripe keys', () => {
|
|
expect(detectSecrets('sk_live_51AbCdEfGhIjKlMnOpQrStUvWxYz')).toBe('stripe-secret');
|
|
});
|
|
|
|
it('detects private key blocks', () => {
|
|
expect(detectSecrets('-----BEGIN RSA PRIVATE KEY-----\nMII...')).toBe('private-key-block');
|
|
});
|
|
|
|
it('detects JWT tokens', () => {
|
|
const jwt = 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
|
|
expect(detectSecrets(jwt)).toBe('jwt');
|
|
});
|
|
|
|
it('detects basic-auth URLs', () => {
|
|
expect(detectSecrets('Use https://user:hunter2@example.com/api'))
|
|
.toBe('basic-auth-url');
|
|
});
|
|
|
|
it('detects env-var password assignments', () => {
|
|
expect(detectSecrets('PASSWORD=supersecret123'))
|
|
.toBe('env-password');
|
|
});
|
|
|
|
it('detects postgres connection strings with creds', () => {
|
|
expect(detectSecrets('postgres://admin:pw1234@db.local:5432/prod'))
|
|
.toBe('pgsql-url');
|
|
});
|
|
|
|
it('SECRET_PATTERN_NAMES is non-empty and unique', () => {
|
|
expect(SECRET_PATTERN_NAMES.length).toBeGreaterThan(10);
|
|
expect(new Set(SECRET_PATTERN_NAMES).size).toBe(SECRET_PATTERN_NAMES.length);
|
|
});
|
|
});
|
|
|
|
describe('redactSecrets', () => {
|
|
it('replaces every match and reports the patterns that fired', () => {
|
|
const { text, found } = redactSecrets('key AKIAIOSFODNN7EXAMPLE and PASSWORD=supersecret123');
|
|
expect(text).toContain('[REDACTED:aws-access-key]');
|
|
expect(text).toContain('[REDACTED:env-password]');
|
|
expect(text).not.toContain('AKIAIOSFODNN7EXAMPLE');
|
|
expect(found.sort()).toEqual(['aws-access-key', 'env-password']);
|
|
});
|
|
|
|
it('leaves clean text untouched', () => {
|
|
expect(redactSecrets('nothing to hide')).toEqual({ text: 'nothing to hide', found: [] });
|
|
});
|
|
});
|