Skip to content
Open
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
39 changes: 39 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

title = "Custom GitHub Agent Security Scan"

[extend]
useDefault = true

[[rules]]
id = "company-api-key"
description = "Company API Key"
regex = '''COMP_[A-Z0-9]{40}'''
keywords = ["COMP_"]
tags = ["company", "api"]

[[rules]]
id = "slack-token"
description = "Slack API Token"
regex = '''xox[baprs]-[0-9]{10,12}-[0-9]{10,12}-[a-zA-Z0-9]{24}'''
keywords = ["xoxb", "xoxp", "xoxa", "xoxr", "xoxs"]
tags = ["slack", "token"]

[[rules]]
id = "stripe-secret"
description = "Stripe Secret Key"
regex = '''sk_(test|live)_[0-9a-zA-Z]{24}'''
keywords = ["sk_test", "sk_live"]
tags = ["stripe", "secret"]

[[rules]]
id = "supabase-key"
description = "Supabase API Key"
regex = '''[a-zA-Z0-9_-]{20,200}'''
path = '''.*supabase.*'''
keywords = ["supabase"]
tags = ["supabase", "api"]

# Allowlist for false positives
[[rules.allowlists]]
description = "Allow test files"
path = '''.*test.*'''
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# cost-crawler

Codebase analyzer for identifying model/provider selection mechanisms and cost implications in LLM-integrated projects.

## Stack

- TypeScript (Node.js)
- `@babel/parser` + `@babel/traverse` for AST analysis
- `commander` for CLI
- Jest for tests

## Install

```bash
npm install
```

## Build

```bash
npm run build
```

## Test

```bash
npm test
```

## CLI Usage

```bash
# Analyze a codebase using default patterns (src/**/*.ts, src/**/*.js)
node bin/cost-crawler.js analyze <repoPath>

# Specify custom glob patterns
node bin/cost-crawler.js analyze <repoPath> -p "**/*.ts" "**/*.js"

# Output as JSON
node bin/cost-crawler.js analyze <repoPath> -o json

# Write report to file
node bin/cost-crawler.js analyze <repoPath> -f report.json
```

### Example

```bash
node bin/cost-crawler.js analyze /path/to/project -o json -f results.json
```
11 changes: 11 additions & 0 deletions jest-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Suppress localStorage initialization in jest-environment-node
Object.defineProperty(global, 'localStorage', {
value: {
getItem: () => null,
setItem: () => {},
removeItem: () => {},
clear: () => {},
},
writable: true,
configurable: true,
});
9 changes: 2 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ module.exports = {
testMatch: ['**/tests/**/*.test.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts'],
setupFiles: ['<rootDir>/jest-setup.js'],
testEnvironmentOptions: {
autoUseFakeTimers: false,
localstoragePath: path.join(__dirname, '.jest-localStorage'),
},
globals: {
'ts-jest': {
isolatedModules: true,
},
localstoragePath: path.join(__dirname, '.jest-tmp-localStorage'),
},
};
3 changes: 3 additions & 0 deletions package-lock.json

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