Skip to content

Commit

Permalink
warn once
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-messiah committed Jan 14, 2025
1 parent ae333ee commit 9adf112
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/common/util/obfuscate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import { warn } from './console'
export class Obfuscator {
constructor (agentRef) {
this.agentRef = agentRef
this.warnedRegexMissing = false
this.warnedInvalidRegex = false
this.warnedInvalidReplacement = false
}

get obfuscateConfigRules () {
Expand Down Expand Up @@ -63,9 +66,17 @@ export class Obfuscator {
const invalidRegexDetected = Boolean(rule.regex !== undefined && typeof rule.regex !== 'string' && !(rule.regex instanceof RegExp))
const invalidReplacementDetected = Boolean(rule.replacement && typeof rule.replacement !== 'string')

if (regexMissingDetected) warn(12, rule)
else if (invalidRegexDetected) warn(13, rule)
if (invalidReplacementDetected) warn(14, rule)
if (regexMissingDetected && !this.warnedRegexMissing) {
warn(12, rule)
this.warnedRegexMissing = true
} else if (invalidRegexDetected && !this.warnedInvalidRegex) {
warn(13, rule)
this.warnedInvalidRegex = true
}
if (invalidReplacementDetected && !this.warnedInvalidReplacement) {
warn(14, rule)
this.warnedInvalidReplacement = true
}

return {
rule,
Expand Down

0 comments on commit 9adf112

Please sign in to comment.