Skip to content

Commit bccddb4

Browse files
author
Maxim Titovich
committed
Enhance security: Add protections for sensitive data in git and npm
1 parent 534eca5 commit bccddb4

File tree

4 files changed

+152
-16
lines changed

4 files changed

+152
-16
lines changed

.gitignore

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1+
# Dependencies
12
node_modules/
3+
4+
# Build outputs
25
build/
36
dist/
47
lib/
8+
9+
# Development and backups
510
backup/
6-
.env
11+
.vscode/
12+
.idea/
713
*.log
14+
logs/
15+
*.swp
16+
.DS_Store
17+
18+
# Environment and secrets
19+
.env
20+
.env.*
21+
!.env.example
22+
*.pem
23+
*.key
24+
*.crt
25+
26+
# Temp files
27+
tmp/
28+
temp/
29+
.cache/
30+
31+
# npm package files
32+
*.tgz
33+
.npm

.npmignore

+42-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,48 @@
1+
# Source files
2+
src/
3+
tests/
4+
.typescript/
5+
tsconfig.json
6+
*.map
7+
18
# Development files
2-
.env
3-
.env.example
49
.git
10+
.github
511
.gitignore
12+
.prettierrc.json
13+
.prettierignore
14+
.eslintrc.json
15+
.eslintignore
616
.vscode
17+
.idea
18+
.editorconfig
19+
20+
# CI/CD
21+
.travis.yml
22+
.gitlab-ci.yml
23+
.github/
24+
.circleci/
25+
26+
# Docs and examples
27+
docs/
28+
examples/
29+
*.md
30+
!README.md
31+
32+
# Environment and secrets
33+
.env
34+
.env.*
35+
!.env.example
36+
*.pem
37+
*.key
38+
*.crt
39+
40+
# Logs and backups
41+
logs/
42+
*.log
43+
backup/
744
.DS_Store
8-
# Test files
9-
test-*.js
10-
*.test.js
11-
# Server files
12-
server.js
13-
mcp-handler.js
14-
cursor-client-example.js
45+
*.swp
46+
1547
# Node modules
16-
node_modules
48+
node_modules/

package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010
},
1111
"files": [
1212
"build",
13-
"README.md"
13+
"README.md",
14+
".env.example"
1415
],
1516
"scripts": {
1617
"start": "node build/index.js",
1718
"dev": "tsc -w",
1819
"test-connection": "node build/test-connection.js",
1920
"sse-server": "node build/sse-server.js",
2021
"build": "npm run format && tsc && node -e \"require('fs').chmodSync('build/index.js', '755') && require('fs').chmodSync('build/sse-server.js', '755')\"",
21-
"prepublishOnly": "npm run check && npm run build",
22+
"prepublishOnly": "npm run check && npm run build && npm run security-check",
23+
"security-check": "node security-check.js",
2224
"lint": "eslint . --ext .ts",
2325
"lint:fix": "eslint . --ext .ts --fix",
2426
"format": "prettier --write \"src/**/*.ts\"",
@@ -59,10 +61,10 @@
5961
},
6062
"repository": {
6163
"type": "git",
62-
"url": "git+https://github.com/yourusername/cursor-azure-devops-mcp.git"
64+
"url": "git+https://github.com/maximtitovich/cursor-azure-devops-mcp.git"
6365
},
6466
"bugs": {
65-
"url": "https://github.com/yourusername/cursor-azure-devops-mcp/issues"
67+
"url": "https://github.com/maximtitovich/cursor-azure-devops-mcp/issues"
6668
},
67-
"homepage": "https://github.com/yourusername/cursor-azure-devops-mcp#readme"
69+
"homepage": "https://github.com/maximtitovich/cursor-azure-devops-mcp#readme"
6870
}

security-check.js

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script to check for sensitive files that should not be committed
5+
* Run this before committing or as part of a pre-commit hook
6+
*/
7+
8+
import fs from 'fs';
9+
import { execSync } from 'child_process';
10+
11+
// Files that should never be committed
12+
const SENSITIVE_FILES = [
13+
'.env',
14+
'.env.local',
15+
'.env.development',
16+
'.env.production',
17+
'.env.test',
18+
'credentials.json',
19+
'secrets.json',
20+
'token.json',
21+
'keys.json',
22+
'*.pem',
23+
'*.key',
24+
'*.crt',
25+
'*.pfx',
26+
'*.p12'
27+
];
28+
29+
console.log('Running security check...');
30+
31+
// Check for sensitive files in the git working directory
32+
let filesFound = false;
33+
34+
for (const pattern of SENSITIVE_FILES) {
35+
// Skip glob patterns
36+
if (pattern.includes('*')) continue;
37+
38+
// Check if file exists and is not ignored by git
39+
if (fs.existsSync(pattern)) {
40+
try {
41+
// Check if file is already ignored by git
42+
execSync(`git check-ignore -q ${pattern}`);
43+
} catch (error) {
44+
// File exists and is not ignored
45+
console.error(`❌ Error: Sensitive file "${pattern}" found and is not ignored by git.`);
46+
filesFound = true;
47+
}
48+
}
49+
}
50+
51+
// Check for pattern matches (like *.pem files)
52+
try {
53+
const allFiles = execSync('git ls-files').toString().split('\n').filter(Boolean);
54+
55+
for (const file of allFiles) {
56+
for (const pattern of SENSITIVE_FILES) {
57+
if (pattern.includes('*')) {
58+
const regex = new RegExp(pattern.replace('.', '\\.').replace('*', '.*'));
59+
if (regex.test(file)) {
60+
console.error(`❌ Error: Sensitive file "${file}" matching pattern "${pattern}" is tracked by git.`);
61+
filesFound = true;
62+
}
63+
}
64+
}
65+
}
66+
} catch (error) {
67+
console.error('❌ Error checking git files:', error.message);
68+
}
69+
70+
if (filesFound) {
71+
console.error('❌ Security check failed. Please remove the sensitive files or add them to .gitignore.');
72+
process.exit(1);
73+
} else {
74+
console.log('✅ Security check passed. No sensitive files detected.');
75+
process.exit(0);
76+
}

0 commit comments

Comments
 (0)