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
6 changes: 6 additions & 0 deletions src/checker/taint/common-kit/source-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ function introduceFuncArgTaintByRuleConfig(scope: any, node: any, callInfo: Call
}
break
}
} else if (call.name === tspec.fsig) {
const args = prepareArgs(callInfo, undefined, tspec)
for (let i = 0; i < args.length; i++) {
markTaintSource(args[i], { path: node, kind: tspec.kind })
}
break
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/checker/taint/js/js-taint-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,22 @@ class JsTaintChecker extends TaintChecker {
}
}
}

/**
*
* @param analyzer
* @param scope
* @param node
* @param state
* @param info
*/
triggerAtNewExprAfter(analyzer: any, scope: any, node: any, state: any, info: any) {
if (config.analyzer !== 'JavaScriptAnalyzer') {
return
}
const { fclos, callInfo } = info
this.checkSinkAtFunctionCall(node, fclos, callInfo, state)
}

/**
*
Expand Down
39 changes: 25 additions & 14 deletions src/engine/analyzer/javascript/common/js-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,24 +835,35 @@ class JsAnalyzer extends Analyzer {
// handle ext
if (!fs.existsSync(pathname) || !fs.statSync(pathname).isFile()) {
let isExist = false
let cwd
let filename

cwd = path.join(pathname, '../')
filename = pathname.split('/').pop()
const files = [`${filename}.(js|ts|mjs|cjs)`]
const filepaths = globby.sync(files, { cwd, caseSensitiveMatch: false })
if (filepaths && filepaths.length !== 0) {
pathname = path.join(cwd, filepaths[0])
isExist = true
} else if (fs.existsSync(pathname)) {
cwd = pathname
filename = '(i|I)ndex'

if (pathname.endsWith('.js')) { // handle ts
const tsPathname = pathname.replace(/\.js$/, '.ts')
if (fs.existsSync(tsPathname) && fs.statSync(tsPathname).isFile()) {
pathname = tsPathname
isExist = true
}
}

if (!isExist) {
let cwd
let filename

cwd = path.join(pathname, '../')
filename = pathname.split('/').pop()
const files = [`${filename}.(js|ts|mjs|cjs)`]
const filepaths = globby.sync(files, { cwd, caseSensitiveMatch: false })
if (filepaths && filepaths.length !== 0) {
pathname = path.join(pathname, filepaths[0])
pathname = path.join(cwd, filepaths[0])
isExist = true
} else if (fs.existsSync(pathname)) {
cwd = pathname
filename = '(i|I)ndex'
const files = [`${filename}.(js|ts|mjs|cjs)`]
const filepaths = globby.sync(files, { cwd, caseSensitiveMatch: false })
if (filepaths && filepaths.length !== 0) {
pathname = path.join(pathname, filepaths[0])
isExist = true
}
}
}

Expand Down
Loading