Skip to content
Merged
Show file tree
Hide file tree
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
35 changes: 25 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,47 @@ on:
pull_request:
branches: [main, develop]

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
test:
name: Run tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.2

- uses: actions/setup-node@v4
- uses: pnpm/action-setup@v4
with:
node-version: '22'
version: 9

- uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4.4.0
with:
version: 9
node-version: '22'
cache: 'pnpm'

- name: Install system dependencies for better-sqlite3
run: sudo apt-get install -y python3 make g++

- run: pnpm install --build-from-source
- name: Install dependencies
run: pnpm install

- run: pnpm typecheck
- name: Rebuild better-sqlite3 for CI environment
run: pnpm rebuild better-sqlite3

- run: pnpm test
- name: Type check
run: pnpm typecheck

- name: Run tests
run: pnpm test

privacy-audit:
name: Privacy constraint check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.2

- name: Check for forbidden patterns
run: |
Expand All @@ -48,4 +63,4 @@ jobs:
echo "Privacy check FAILED"
exit 1
fi
echo "✅ Privacy check passed"
echo "✅ Privacy check passed"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.13",
"typescript": "~5.4.5",
"vitest": "^4.1.8"
}
}
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/privacy/audit-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ export class AuditLog {
* This can be called by the user from the Privacy Dashboard to prove
* that no historical records have been modified.
*/
verifyChain(): { valid: boolean; broken_at?: number; total_records: number } {
verifyChain(): { valid: boolean; broken_at: number | undefined; total_records: number } {
const rows = this.db.prepare(`
SELECT * FROM audit_log ORDER BY id ASC
`).all() as AuditEntry[]

let prevHash: string | null = null

for (const row of rows) {
const content = [
const content: string = [
row.timestamp,
row.event_type,
row.app_name,
Expand All @@ -143,8 +143,7 @@ export class AuditLog {
row.details,
prevHash,
].join('|')

const expectedHash = createHash('sha256').update(content).digest('hex')
const expectedHash: string = createHash('sha256').update(content).digest('hex')

if (expectedHash !== row.record_hash) {
return { valid: false, broken_at: row.id, total_records: rows.length }
Expand All @@ -153,7 +152,7 @@ export class AuditLog {
prevHash = row.record_hash
}

return { valid: true, total_records: rows.length }
return { valid: true, broken_at: undefined, total_records: rows.length }
}

/**
Expand Down
Loading