CI/CD Tools
Test privacy in your development workflow.
Installation
npm install --save-dev solana-privacy-scanner-ci-tools
Quick Setup
npx privacy-scanner-init
Interactive wizard creates:
.privacyrcconfiguration- GitHub Actions workflow (optional)
- Pre-commit hooks (optional)
- Test setup (optional)
Features
Transaction Simulator
Test privacy before sending to chain:
import { simulateTransactionPrivacy } from 'solana-privacy-scanner-ci-tools/simulator';
const tx = await buildTransaction();
const report = await simulateTransactionPrivacy(tx, connection);
if (report.overallRisk === 'HIGH') {
throw new Error('Privacy policy violated');
}
Testing Matchers
Privacy assertions in tests:
import 'solana-privacy-scanner-ci-tools/matchers';
test('transfer maintains privacy', async () => {
const report = await simulateTransactionPrivacy(tx, connection);
expect(report).toHavePrivacyRisk('LOW');
expect(report).toNotLeakUserRelationships();
});
Configuration
.privacyrc for project policies:
{
"maxRiskLevel": "MEDIUM",
"enforceInCI": true,
"thresholds": {
"maxHighSeverity": 0
}
}
GitHub Actions
Auto-generated workflow:
name: Privacy Check
on: [pull_request]
jobs:
privacy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm test
Examples
DeFi Protocol
test('lending maintains privacy', async () => {
const borrowTx = await protocol.borrow(amount);
const report = await simulateTransactionPrivacy(borrowTx, connection);
expect(report).toHaveNoHighRiskSignals();
expect(report).toNotInteractWith('exchange');
});
Flow Analysis
const flow = [depositTx, swapTx, withdrawTx];
const flowReport = await simulateTransactionFlow(flow, connection);
expect(flowReport.cumulativeRisk).not.toBe('HIGH');
Implementation Comparison
const comparison = await compareImplementations(
directTransfer,
routedTransfer,
connection
);
console.log(`Winner: ${comparison.winner}`);
Next Steps
- Testing Guide - Write privacy tests
- GitHub Actions - CI/CD setup
- For LLMs - AI assistant guide