Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/projectRulesEngine.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { describe, expect, it } from 'vitest';
import { ProjectGraph } from '../src/graph/projectGraph';
import { ProjectRulesEngine } from '../src/rules/projectRulesEngine';

describe('ProjectRulesEngine', () => {
it('should parse default rules when no file exists', () => {
const engine = new ProjectRulesEngine('/nonexistent/workspace');
const rules = engine.parseRules();
expect(rules.length).toBeGreaterThanOrEqual(4);
expect(rules.some((r) => r.title.toLowerCase().includes('authentication'))).toBe(true);
});

it('should detect passwordHash leakage in response objects', async () => {
const engine = new ProjectRulesEngine(process.cwd());
const graph = new ProjectGraph(process.cwd());

const fakeDiff = [
{
oldPath: 'src/api/user.ts',
newPath: 'src/api/user.ts',
isNew: false,
isDeleted: false,
isRenamed: false,
hunks: [],
addedLines: [1],
deletedLines: [],
modifiedLineRanges: [{ start: 1, end: 1 }]
}
];

// Evaluate against rule directly
const rule = {
id: 'RULE-2',
title: 'Sensitive Field Protection',
description: 'Never expose passwordHash or secret fields in responses.',
severity: 'HIGH' as const
};

expect(rule.description).toContain('passwordHash');
});
});
Loading