MCPcopy Create free account
hub / github.com/Silentely/eSIM-Tools / checkSecurityConfig

Function checkSecurityConfig

scripts/security-check.js:119–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117
118// 检查开发环境安全配置
119function checkSecurityConfig() {
120 BuildLogger.log('\n🔧 安全配置检查:\n');
121
122 // 检查Helmet配置
123 const serverPath = path.join(__dirname, '../server.js');
124 if (fs.existsSync(serverPath)) {
125 const serverContent = fs.readFileSync(serverPath, 'utf8');
126 if (serverContent.includes('helmet')) {
127 BuildLogger.success(' Helmet安全头已配置');
128 } else {
129 BuildLogger.warn(' 建议添加Helmet安全头');
130 }
131 }
132
133 // 检查CORS配置
134 if (fs.existsSync(serverPath)) {
135 const serverContent = fs.readFileSync(serverPath, 'utf8');
136 if (serverContent.includes('cors')) {
137 BuildLogger.success(' CORS配置已设置');
138 } else {
139 BuildLogger.warn(' 建议配置CORS');
140 }
141 }
142
143 // 检查Content Security Policy
144 const htmlFiles = [
145 'index.html',
146 'src/giffgaff/giffgaff_modular.html',
147 'src/simyo/simyo_modular.html'
148 ];
149
150 htmlFiles.forEach(file => {
151 const filePath = path.join(__dirname, '..', file);
152 if (fs.existsSync(filePath)) {
153 const content = fs.readFileSync(filePath, 'utf8');
154 if (content.includes('Content-Security-Policy')) {
155 BuildLogger.success(` ${file} 已配置CSP`);
156 } else {
157 BuildLogger.warn(` ${file} 建议添加CSP配置`);
158 }
159 }
160 });
161}
162
163// 主函数
164function main() {

Callers 1

mainFunction · 0.85

Calls 3

logMethod · 0.45
successMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected