UNPKG

@hclsoftware/secagent

Version:

IAST agent

110 lines (89 loc) 2.58 kB
//IASTIGNORE /* * **************************************************** * Licensed Materials - Property of HCL. * (c) Copyright HCL Technologies Ltd. 2017, 2025. * Note to U.S. Government Users *Restricted Rights. * **************************************************** */ const CONSTRUCTOR_NAME = '' class HookValues { constructor (args, that, origMethod, methodSignature = '', additionalInfo = null, callbackRules = null, constructorProxy=null) { this.args = args this.that = that this.isConstructor = constructorProxy !== null this.origMethod = origMethod this.methodName = this.getFinalMethodName(methodSignature, origMethod, this.isConstructor) this._additionalInfo = additionalInfo this._runOrigMethod = true this.newTarget = constructorProxy this.callbackRules = callbackRules } getFinalMethodName (baseName, origMethod, isConstructor) { let methodName = baseName === '' ? origMethod.name : baseName if (isConstructor) { methodName += '.<init>' } return methodName } get runOrigMethod() { return this._runOrigMethod } set runOrigMethod(value) { this._runOrigMethod = value } get ret () { return this._ret } set ret (ret) { this._ret = ret } get simpleRet () { if (this._simpleRet != null) { try { return this._simpleRet !== CONSTRUCTOR_NAME || this.ret == null ? this._simpleRet : this.ret.constructor.name } catch (error) { return '' } } return this.ret } set simpleRet (simpleRet) { this._simpleRet = simpleRet } get updatedArgs () { return this.newArgs != null ? this.newArgs : this.args } set updatedArgs (newArgs) { this.newArgs = newArgs } get updatedThat () { return this.newThat != null ? this.newThat : this.that } set updatedThat (newThat) { this.newThat = newThat } get simpleThat () { return this._simpleThat != null ? this._simpleThat : this.that } set simpleThat (simpleThat) { this._simpleThat = simpleThat } get simpleArgs () { return this._simpleArgs != null ? this._simpleArgs : this.args } setSimpleArgAt (index, arg) { if (this._simpleArgs == null) { this._simpleArgs = require('lodash').cloneDeep(this.args) } this._simpleArgs[index] = arg } get additionalInfo () { return this._additionalInfo } set additionalInfo (info) { this._additionalInfo = info } } module.exports = HookValues module.exports.CONSTRUCTOR_NAME = CONSTRUCTOR_NAME