From 650115f53eceb8749d9a0d1e3bf0adb40edd528f Mon Sep 17 00:00:00 2001 From: Eric Murray Date: Mon, 5 Aug 2024 14:03:52 +0100 Subject: [PATCH] Create camara-security-no-secrets-in-path-or-query-parameters.js --- ...-no-secrets-in-path-or-query-parameters.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lint_function/camara-security-no-secrets-in-path-or-query-parameters.js diff --git a/lint_function/camara-security-no-secrets-in-path-or-query-parameters.js b/lint_function/camara-security-no-secrets-in-path-or-query-parameters.js new file mode 100644 index 0000000..ebbff2a --- /dev/null +++ b/lint_function/camara-security-no-secrets-in-path-or-query-parameters.js @@ -0,0 +1,26 @@ +// CAMARA Project - support function for Spectral linter +// 31.01.2024 - initial version + +const sensitiveData = ['MSISDN','IMSI','phoneNumber']; + +export default async function (input) { + + // Iterate over properties of the input object + for (const path in input) { + + if (typeof path === 'string') { + for (const word of sensitiveData ) { + const regex = new RegExp(`\\b${word}\\b`, 'g'); // Use a regular expression to match 'word' as a standalone word + + if (regex.test(path)) { + + const warningRuleName = 'camara-security-no-secrets-in-path-or-query-parameters'; + const description = `sensitiveData Data found in path: Consider avoiding the use of sensitiveData data '${word}'`; + const location = `paths.${path}`; + console.log(`warning ${warningRuleName} ${description} ${location}`); + + } + } + } + } +}