Adjust Debug Statements severity based on path
mainThe Debug Statements security rule (triggered by excessive console.log, console.debug, or console.info calls) should have its severity adjusted based on whether the file is part of the backend architecture.
- Backend/Server paths: Severity should be
info. - Client/Other paths: Severity should be
low.
This uses the isArchitectureBackendPath(path) classifier to determine the appropriate level.
if(scanContent.match(/console\.(log|debug|info)\(\)){
var consoleCount=(scanContent.match(/console\.(log|debug|info)\(\)/g)||[]).length;
if(consoleCount>3){
var debugSeverity=isArchitectureBackendPath(f.path)?'info':'low';
issues.push({
severity:debugSeverity,
title:'Debug Statements',
file:f.name,
path:f.path,
desc:consoleCount+' console statements found. Remove before production.',
code:''
});
}
}