@hclsoftware/secagent
Version:
IAST agent
51 lines (45 loc) • 1.68 kB
JavaScript
//IASTIGNORE
/*
* ****************************************************
* Licensed Materials - Property of HCL.
* (c) Copyright HCL Technologies Ltd. 2017, 2025.
* Note to U.S. Government Users *Restricted Rights.
* ****************************************************
*/
const BeforeRule = require('./BeforeRule')
/**
* Used to convert args using the rule which extends this class, for specific use cases
* @class ConvertArgsRule
* @see BeforeRule
*/
module.exports = class ConvertArgsRule extends BeforeRule {
doRule (hookValues) {
const newArgs = new Array(hookValues.updatedArgs.length)
const applyForIndices = this.data.applyFor
for (let i = 0; i < hookValues.updatedArgs.length; i++) {
// eslint-disable-next-line eqeqeq
// noinspection EqualityComparisonWithCoercionJS
if ((applyForIndices === 'all' || applyForIndices.some(idx => idx == i)) && this.additionalChecks(hookValues.updatedArgs[i])) {
newArgs[i] = this.convert(hookValues.updatedArgs[i])
} else {
newArgs[i] = hookValues.updatedArgs[i]
}
}
hookValues.updatedArgs = newArgs
}
// abstract-like method.
additionalChecks(input) {
console.origLog('Warning [IAST Secagent] should not be called. Implement additionalChecks method in each specific convert rule')
}
/**
* @abstract convert
* @param input
* @returns {*}
*/
convert(input) {
console.origLog('Warning [IAST Secagent] should not be called. Implement convert method in each specific convert rule')
}
runWhenInactive(){
return true;
}
}