snyk 1.783.0 → 1.784.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/cli/85.index.js +2 -2
- package/dist/cli/85.index.js.map +1 -1
- package/dist/cli/917.index.js +2 -1
- package/dist/cli/917.index.js.map +1 -1
- package/help/README.md +9 -8
- package/help/{commands-md → cli-commands}/snyk-auth.md +10 -26
- package/help/{commands-md → cli-commands}/snyk-code.md +11 -27
- package/help/{commands-md → cli-commands}/snyk-config.md +11 -27
- package/help/{commands-md → cli-commands}/snyk-container.md +11 -27
- package/help/{commands-md → cli-commands}/snyk-iac.md +12 -27
- package/help/{commands-md → cli-commands}/snyk-ignore.md +10 -25
- package/help/{commands-md → cli-commands}/snyk-monitor.md +14 -53
- package/help/{commands-md → cli-commands}/snyk-policy.md +10 -26
- package/help/{commands-md → cli-commands}/snyk-protect.md +10 -26
- package/help/{commands-md → cli-commands}/snyk-test.md +10 -55
- package/help/{commands-md → cli-commands}/snyk-wizard.md +10 -26
- package/help/{commands-md → cli-commands}/snyk.md +0 -0
- package/package.json +4 -5
- package/help/commands-md/snyk-help.md +0 -99
- package/help/commands-md/snyk-woof.md +0 -103
package/README.md
CHANGED
|
@@ -274,4 +274,10 @@ This repository is a monorepo, also covering other projects and tools:
|
|
|
274
274
|
|
|
275
275
|
For any security issues or concerns, please see [SECURITY.md](SECURITY.md) file in this repository.
|
|
276
276
|
|
|
277
|
+
## Notices
|
|
278
|
+
|
|
279
|
+
### Snyk API usage policy
|
|
280
|
+
|
|
281
|
+
The use of Snyk's API, whether through the use of the 'snyk' npm package or otherwise, is subject to the [Terms & Conditions](https://snyk.co/ucT6N).
|
|
282
|
+
|
|
277
283
|
Made with 💜 by Snyk
|
package/dist/cli/85.index.js
CHANGED
|
@@ -24,12 +24,12 @@ async function help(item) {
|
|
|
24
24
|
// aka: /\W/g but figured this was easier to read
|
|
25
25
|
item = item.replace(/[^a-z-]/gi, '');
|
|
26
26
|
try {
|
|
27
|
-
const filename = path.resolve(__dirname, '../../help/commands
|
|
27
|
+
const filename = path.resolve(__dirname, '../../help/cli-commands', // this is a relative path from the webpack dist directory
|
|
28
28
|
item === DEFAULT_HELP ? `${DEFAULT_HELP}.md` : `snyk-${item}.md`);
|
|
29
29
|
return readHelpFile(filename);
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
|
-
const filename = path.resolve(__dirname, '../../help/commands
|
|
32
|
+
const filename = path.resolve(__dirname, '../../help/cli-commands', `${DEFAULT_HELP}.md`);
|
|
33
33
|
return readHelpFile(filename);
|
|
34
34
|
}
|
|
35
35
|
}
|
package/dist/cli/85.index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"85.index.js","mappings":";;;;;;;;;;AAAA,sCAAyB;AACzB,wCAA6B;AAC7B,uDAAqD;AAErD,MAAM,YAAY,GAAG,MAAM,CAAC;AAE5B,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,kCAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAEc,KAAK,UAAU,IAAI,CAAC,IAAuB;IACxD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,EAAE;QACzE,IAAI,GAAG,YAAY,CAAC;KACrB;IAED,+CAA+C;IAC/C,iDAAiD;IACjD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAErC,IAAI;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAC3B,SAAS,EACT,wBAAwB,EAAE,0DAA0D;QACpF,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,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AAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAhGD,gCAgGC","sources":["webpack://snyk/./src/cli/commands/help/index.ts","webpack://snyk/./src/cli/commands/help/markdown-renderer.ts","webpack://snyk/./src/cli/commands/help/reflow-text.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { renderMarkdown } from './markdown-renderer';\n\nconst DEFAULT_HELP = 'snyk';\n\nfunction readHelpFile(filename: string): string {\n const file = fs.readFileSync(filename, 'utf8');\n return renderMarkdown(file);\n}\n\nexport default async function help(item?: string | boolean): Promise<string> {\n if (!item || item === true || typeof item !== 'string' || item === 'help') {\n item = DEFAULT_HELP;\n }\n\n // cleanse the filename to only contain letters\n // aka: /\\W/g but figured this was easier to read\n item = item.replace(/[^a-z-]/gi, '');\n\n try {\n const filename = path.resolve(\n __dirname,\n '../../help/commands-md', // this is a relative path from the webpack dist directory\n item === DEFAULT_HELP ? `${DEFAULT_HELP}.md` : `snyk-${item}.md`,\n );\n return readHelpFile(filename);\n } catch (error) {\n const filename = path.resolve(\n __dirname,\n '../../help/commands-md',\n `${DEFAULT_HELP}.md`,\n );\n return readHelpFile(filename);\n }\n}\n","import { marked } from 'marked';\nimport chalk from 'chalk';\nimport { reflowText } from './reflow-text';\n\n// stateful variable to control left-padding by header level\nlet currentHeader = 1;\nconst listItemSeparator = 'LISTITEMSEPARATOR'; // Helper string for rendering ListItems\n\n/**\n * @description get padding spaces depending on the last header level used\n * @returns string\n */\nfunction getLeftTextPadding(): string {\n return ' '.repeat(\n currentHeader === 1 || currentHeader === 2 ? 1 : currentHeader - 1,\n );\n}\n\n/**\n * @description Reads current terminal width if available to limit column width for text-reflowing\n * @returns {number}\n */\nconst defaultMaximumLineWidth = 100;\nfunction getIdealTextWidth(maximumLineWidth = defaultMaximumLineWidth): number {\n if (typeof process.stdout.columns === 'number') {\n if (process.stdout.columns < maximumLineWidth) {\n return process.stdout.columns - getLeftTextPadding().length - 5;\n }\n }\n return maximumLineWidth - getLeftTextPadding().length;\n}\n\n// Marked custom renderer class\nconst renderer = {\n em(text) {\n return chalk.italic(text);\n },\n strong(text) {\n return chalk.bold(text);\n },\n link(href, title, text) {\n const renderedLink = chalk.bold.blueBright(href);\n if (text && text !== href) {\n return `${text} ${renderedLink}`;\n }\n return renderedLink;\n },\n blockquote(quote) {\n return quote;\n },\n list(body, ordered, start) {\n return body\n .split(listItemSeparator)\n .map((listItem, listItemIndex) => {\n const bulletPoint = ordered ? `${listItemIndex + start}. ` : '- ';\n return reflowText(listItem, getIdealTextWidth())\n .split('\\n')\n .map((listItemLine, listItemLineIndex) => {\n if (!listItemLine) {\n return '';\n }\n return `${getLeftTextPadding()}${\n listItemLineIndex === 0 ? bulletPoint : ' '\n }${listItemLine}`;\n })\n .join('\\n');\n })\n .join('\\n');\n },\n listitem(text) {\n return text + listItemSeparator;\n },\n paragraph(text) {\n return (\n reflowText(text, getIdealTextWidth())\n .split('\\n')\n .map((s) => getLeftTextPadding() + chalk.reset() + s)\n .join('\\n') + '\\n'\n );\n },\n codespan(text) {\n return chalk.italic.blueBright(`${text}`);\n },\n code(code) {\n return code + '\\n';\n },\n heading(text, level) {\n currentHeader = level;\n let coloring;\n switch (level) {\n case 1:\n coloring = chalk.bold.underline;\n break;\n case 3:\n case 4:\n coloring = chalk;\n break;\n default:\n coloring = chalk.bold;\n break;\n }\n return `\\n${' '.repeat(level === 1 ? 0 : currentHeader - 2)}${coloring(\n text,\n )}\\n`;\n },\n};\n\nmarked.use({ renderer });\nmarked.setOptions({\n mangle: false,\n});\n\nconst htmlUnescapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n '`': '`',\n};\n\n/**\n * @description Replace HTML entities with their non-encoded variant\n * @param {string} text\n * @returns {string}\n */\nfunction unescape(text: string): string {\n Object.entries(htmlUnescapes).forEach(([escapedChar, unescapedChar]) => {\n const escapedCharRegExp = new RegExp(escapedChar, 'g');\n text = text.replace(escapedCharRegExp, unescapedChar);\n });\n return text;\n}\n\nexport function renderMarkdown(markdown: string): string {\n return unescape(marked.parse(markdown));\n}\n","/**\nCode in this file is adapted from mikaelbr/marked-terminal\nhttps://github.com/mikaelbr/marked-terminal/blob/7501b8bb24a5ed52ec7d9114d4aeefa14f1bf5e6/index.js#L234-L330\n\n\nMIT License\n\nCopyright (c) 2017 Mikael Brevik\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n */\n\n// Compute length of str not including ANSI escape codes.\n// See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\nfunction textLength(str: string): number {\n // eslint-disable-next-line no-control-regex\n return str.replace(/\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m/g, '').length;\n}\n\n// Munge \\n's and spaces in \"text\" so that the number of\n// characters between \\n's is less than or equal to \"width\".\nexport function reflowText(text: string, width: number): string {\n const HARD_RETURN = '\\r|\\n';\n const HARD_RETURN_GFM_RE = new RegExp(HARD_RETURN + '|<br />');\n\n const splitRe = HARD_RETURN_GFM_RE;\n const sections = text.split(splitRe);\n const reflowed = [] as string[];\n\n sections.forEach((section) => {\n // Split the section by escape codes so that we can\n // deal with them separately.\n // eslint-disable-next-line no-control-regex\n const fragments = section.split(/(\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m)/g);\n let column = 0;\n let currentLine = '';\n let lastWasEscapeChar = false;\n\n while (fragments.length) {\n const fragment = fragments[0];\n\n if (fragment === '') {\n fragments.splice(0, 1);\n lastWasEscapeChar = false;\n continue;\n }\n\n // This is an escape code - leave it whole and\n // move to the next fragment.\n if (!textLength(fragment)) {\n currentLine += fragment;\n fragments.splice(0, 1);\n lastWasEscapeChar = true;\n continue;\n }\n\n const words = fragment.split(/[ \\t\\n]+/);\n\n for (let i = 0; i < words.length; i++) {\n let word = words[i];\n let addSpace = column != 0;\n if (lastWasEscapeChar) addSpace = false;\n\n // If adding the new word overflows the required width\n if (column + word.length > width) {\n if (word.length <= width) {\n // If the new word is smaller than the required width\n // just add it at the beginning of a new line\n reflowed.push(currentLine);\n currentLine = word;\n column = word.length;\n } else {\n // If the new word is longer than the required width\n // split this word into smaller parts.\n const w = word.substr(0, width - column);\n if (addSpace) currentLine += ' ';\n currentLine += w;\n reflowed.push(currentLine);\n currentLine = '';\n column = 0;\n\n word = word.substr(w.length);\n while (word.length) {\n const w = word.substr(0, width);\n\n if (!w.length) break;\n\n if (w.length < width) {\n currentLine = w;\n column = w.length;\n break;\n } else {\n reflowed.push(w);\n word = word.substr(width);\n }\n }\n }\n } else {\n if (addSpace) {\n currentLine += ' ';\n column++;\n }\n\n currentLine += word;\n column += word.length;\n }\n\n lastWasEscapeChar = false;\n }\n\n fragments.splice(0, 1);\n }\n\n if (textLength(currentLine)) reflowed.push(currentLine);\n });\n\n return reflowed.join('\\n');\n}\n"],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"85.index.js","mappings":";;;;;;;;;;AAAA,sCAAyB;AACzB,wCAA6B;AAC7B,uDAAqD;AAErD,MAAM,YAAY,GAAG,MAAM,CAAC;AAE5B,SAAS,YAAY,CAAC,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AAM,GAAG,CAAC,CAAC,MAAM,CAAC;gCAClB,MAAM;6BACP;iCAAM;gCACL,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gCACjB,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;6BAC3B;yBACF;qBACF;iBACF;qBAAM;oBACL,IAAI,QAAQ,EAAE;wBACZ,WAAW,IAAI,GAAG,CAAC;wBACnB,MAAM,EAAE,CAAC;qBACV;oBAED,WAAW,IAAI,IAAI,CAAC;oBACpB,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;iBACvB;gBAED,iBAAiB,GAAG,KAAK,CAAC;aAC3B;YAED,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACxB;QAED,IAAI,UAAU,CAAC,WAAW,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAhGD,gCAgGC","sources":["webpack://snyk/./src/cli/commands/help/index.ts","webpack://snyk/./src/cli/commands/help/markdown-renderer.ts","webpack://snyk/./src/cli/commands/help/reflow-text.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { renderMarkdown } from './markdown-renderer';\n\nconst DEFAULT_HELP = 'snyk';\n\nfunction readHelpFile(filename: string): string {\n const file = fs.readFileSync(filename, 'utf8');\n return renderMarkdown(file);\n}\n\nexport default async function help(item?: string | boolean): Promise<string> {\n if (!item || item === true || typeof item !== 'string' || item === 'help') {\n item = DEFAULT_HELP;\n }\n\n // cleanse the filename to only contain letters\n // aka: /\\W/g but figured this was easier to read\n item = item.replace(/[^a-z-]/gi, '');\n\n try {\n const filename = path.resolve(\n __dirname,\n '../../help/cli-commands', // this is a relative path from the webpack dist directory\n item === DEFAULT_HELP ? `${DEFAULT_HELP}.md` : `snyk-${item}.md`,\n );\n return readHelpFile(filename);\n } catch (error) {\n const filename = path.resolve(\n __dirname,\n '../../help/cli-commands',\n `${DEFAULT_HELP}.md`,\n );\n return readHelpFile(filename);\n }\n}\n","import { marked } from 'marked';\nimport chalk from 'chalk';\nimport { reflowText } from './reflow-text';\n\n// stateful variable to control left-padding by header level\nlet currentHeader = 1;\nconst listItemSeparator = 'LISTITEMSEPARATOR'; // Helper string for rendering ListItems\n\n/**\n * @description get padding spaces depending on the last header level used\n * @returns string\n */\nfunction getLeftTextPadding(): string {\n return ' '.repeat(\n currentHeader === 1 || currentHeader === 2 ? 1 : currentHeader - 1,\n );\n}\n\n/**\n * @description Reads current terminal width if available to limit column width for text-reflowing\n * @returns {number}\n */\nconst defaultMaximumLineWidth = 100;\nfunction getIdealTextWidth(maximumLineWidth = defaultMaximumLineWidth): number {\n if (typeof process.stdout.columns === 'number') {\n if (process.stdout.columns < maximumLineWidth) {\n return process.stdout.columns - getLeftTextPadding().length - 5;\n }\n }\n return maximumLineWidth - getLeftTextPadding().length;\n}\n\n// Marked custom renderer class\nconst renderer = {\n em(text) {\n return chalk.italic(text);\n },\n strong(text) {\n return chalk.bold(text);\n },\n link(href, title, text) {\n const renderedLink = chalk.bold.blueBright(href);\n if (text && text !== href) {\n return `${text} ${renderedLink}`;\n }\n return renderedLink;\n },\n blockquote(quote) {\n return quote;\n },\n list(body, ordered, start) {\n return body\n .split(listItemSeparator)\n .map((listItem, listItemIndex) => {\n const bulletPoint = ordered ? `${listItemIndex + start}. ` : '- ';\n return reflowText(listItem, getIdealTextWidth())\n .split('\\n')\n .map((listItemLine, listItemLineIndex) => {\n if (!listItemLine) {\n return '';\n }\n return `${getLeftTextPadding()}${\n listItemLineIndex === 0 ? bulletPoint : ' '\n }${listItemLine}`;\n })\n .join('\\n');\n })\n .join('\\n');\n },\n listitem(text) {\n return text + listItemSeparator;\n },\n paragraph(text) {\n return (\n reflowText(text, getIdealTextWidth())\n .split('\\n')\n .map((s) => getLeftTextPadding() + chalk.reset() + s)\n .join('\\n') + '\\n'\n );\n },\n codespan(text) {\n return chalk.italic.blueBright(`${text}`);\n },\n code(code) {\n return code + '\\n';\n },\n heading(text, level) {\n currentHeader = level;\n let coloring;\n switch (level) {\n case 1:\n coloring = chalk.bold.underline;\n break;\n case 3:\n case 4:\n coloring = chalk;\n break;\n default:\n coloring = chalk.bold;\n break;\n }\n return `\\n${' '.repeat(level === 1 ? 0 : currentHeader - 2)}${coloring(\n text,\n )}\\n`;\n },\n};\n\nmarked.use({ renderer });\nmarked.setOptions({\n mangle: false,\n});\n\nconst htmlUnescapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n '`': '`',\n};\n\n/**\n * @description Replace HTML entities with their non-encoded variant\n * @param {string} text\n * @returns {string}\n */\nfunction unescape(text: string): string {\n Object.entries(htmlUnescapes).forEach(([escapedChar, unescapedChar]) => {\n const escapedCharRegExp = new RegExp(escapedChar, 'g');\n text = text.replace(escapedCharRegExp, unescapedChar);\n });\n return text;\n}\n\nexport function renderMarkdown(markdown: string): string {\n return unescape(marked.parse(markdown));\n}\n","/**\nCode in this file is adapted from mikaelbr/marked-terminal\nhttps://github.com/mikaelbr/marked-terminal/blob/7501b8bb24a5ed52ec7d9114d4aeefa14f1bf5e6/index.js#L234-L330\n\n\nMIT License\n\nCopyright (c) 2017 Mikael Brevik\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n */\n\n// Compute length of str not including ANSI escape codes.\n// See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\nfunction textLength(str: string): number {\n // eslint-disable-next-line no-control-regex\n return str.replace(/\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m/g, '').length;\n}\n\n// Munge \\n's and spaces in \"text\" so that the number of\n// characters between \\n's is less than or equal to \"width\".\nexport function reflowText(text: string, width: number): string {\n const HARD_RETURN = '\\r|\\n';\n const HARD_RETURN_GFM_RE = new RegExp(HARD_RETURN + '|<br />');\n\n const splitRe = HARD_RETURN_GFM_RE;\n const sections = text.split(splitRe);\n const reflowed = [] as string[];\n\n sections.forEach((section) => {\n // Split the section by escape codes so that we can\n // deal with them separately.\n // eslint-disable-next-line no-control-regex\n const fragments = section.split(/(\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m)/g);\n let column = 0;\n let currentLine = '';\n let lastWasEscapeChar = false;\n\n while (fragments.length) {\n const fragment = fragments[0];\n\n if (fragment === '') {\n fragments.splice(0, 1);\n lastWasEscapeChar = false;\n continue;\n }\n\n // This is an escape code - leave it whole and\n // move to the next fragment.\n if (!textLength(fragment)) {\n currentLine += fragment;\n fragments.splice(0, 1);\n lastWasEscapeChar = true;\n continue;\n }\n\n const words = fragment.split(/[ \\t\\n]+/);\n\n for (let i = 0; i < words.length; i++) {\n let word = words[i];\n let addSpace = column != 0;\n if (lastWasEscapeChar) addSpace = false;\n\n // If adding the new word overflows the required width\n if (column + word.length > width) {\n if (word.length <= width) {\n // If the new word is smaller than the required width\n // just add it at the beginning of a new line\n reflowed.push(currentLine);\n currentLine = word;\n column = word.length;\n } else {\n // If the new word is longer than the required width\n // split this word into smaller parts.\n const w = word.substr(0, width - column);\n if (addSpace) currentLine += ' ';\n currentLine += w;\n reflowed.push(currentLine);\n currentLine = '';\n column = 0;\n\n word = word.substr(w.length);\n while (word.length) {\n const w = word.substr(0, width);\n\n if (!w.length) break;\n\n if (w.length < width) {\n currentLine = w;\n column = w.length;\n break;\n } else {\n reflowed.push(w);\n word = word.substr(width);\n }\n }\n }\n } else {\n if (addSpace) {\n currentLine += ' ';\n column++;\n }\n\n currentLine += word;\n column += word.length;\n }\n\n lastWasEscapeChar = false;\n }\n\n fragments.splice(0, 1);\n }\n\n if (textLength(currentLine)) reflowed.push(currentLine);\n });\n\n return reflowed.join('\\n');\n}\n"],"names":[],"sourceRoot":""}
|
package/dist/cli/917.index.js
CHANGED
|
@@ -704,7 +704,8 @@ async function test(pathToScan, options) {
|
|
|
704
704
|
customRulesPath = options.rules;
|
|
705
705
|
}
|
|
706
706
|
const isOCIRegistryURLProvided = checkOCIRegistryURLProvided(iacOrgSettings);
|
|
707
|
-
if (isOCIRegistryURLProvided || customRulesPath)
|
|
707
|
+
if ((isOCIRegistryURLProvided || customRulesPath) &&
|
|
708
|
+
!(options.sarif || options.json)) {
|
|
708
709
|
console.log(chalk_1.default.hex('#ff9b00')('Using custom rules to generate misconfigurations.'));
|
|
709
710
|
}
|
|
710
711
|
if (isOCIRegistryURLProvided && customRulesPath) {
|