diff --git a/content/code-security/secret-scanning/managing-alerts-from-secret-scanning/resolving-alerts.md b/content/code-security/secret-scanning/managing-alerts-from-secret-scanning/resolving-alerts.md index 4ff4dfe4d407..57bcb2517409 100644 --- a/content/code-security/secret-scanning/managing-alerts-from-secret-scanning/resolving-alerts.md +++ b/content/code-security/secret-scanning/managing-alerts-from-secret-scanning/resolving-alerts.md @@ -1,7 +1,7 @@ --- title: Resolving alerts from secret scanning intro: 'After reviewing the details of a secret scanning alert, you should fix and then close the alert.' -permissions: 'Repository owners, organization owners, security managers, commit authors, and users with the **admin** role' +permissions: 'Repository owners, organization owners, security managers, users assigned to {% data variables.secret-scanning.alerts %}, commit authors, and users with the **admin** role' versions: fpt: '*' ghes: '*' diff --git a/src/content-linter/scripts/lint-content.ts b/src/content-linter/scripts/lint-content.ts index 000a681516c2..f84ec31df84d 100755 --- a/src/content-linter/scripts/lint-content.ts +++ b/src/content-linter/scripts/lint-content.ts @@ -127,7 +127,6 @@ program const { fix, - paths, errorsOnly, rules, summaryByRule, @@ -144,8 +143,13 @@ main() async function main() { if (!isOptionsValid()) return + // Get the updated paths after validation (invalid paths will have been filtered out) + const validatedPaths = program.opts().paths + // If paths has not been specified, lint all files - const files = getFilesToLint((summaryByRule && ALL_CONTENT_DIR) || paths || getChangedFiles()) + const files = getFilesToLint( + (summaryByRule && ALL_CONTENT_DIR) || validatedPaths || getChangedFiles(), + ) if (new Set(files.data).size !== files.data.length) throw new Error('Duplicate data files') if (new Set(files.content).size !== files.content.length) @@ -162,7 +166,7 @@ async function main() { const start = Date.now() // Initializes the config to pass to markdownlint based on the input options - const { config, configuredRules } = getMarkdownLintConfig(errorsOnly, rules || []) + const { config, configuredRules } = getMarkdownLintConfig(errorsOnly, rules) // Run Markdownlint for content directory const resultContent = (await markdownlint.promises.markdownlint({ @@ -619,7 +623,7 @@ function listRules() { */ function getMarkdownLintConfig( filterErrorsOnly: boolean, - runRules: string[], + runRules: string[] | undefined, ): MarkdownLintConfigResult { const config = { content: structuredClone(defaultConfig), @@ -793,21 +797,27 @@ function getSearchReplaceRuleSeverity( function isOptionsValid() { // paths should only contain existing files and directories const optionPaths = program.opts().paths || [] + const validPaths = [] + for (const filePath of optionPaths) { try { fs.statSync(filePath) + validPaths.push(filePath) // Keep track of valid paths } catch { if ('paths'.includes(filePath)) { - console.log('error: did you mean --paths') + console.warn('warning: did you mean --paths') } else { - console.log( - `error: invalid --paths (-p) option. The value '${filePath}' is not a valid file or directory`, - ) + console.warn(`warning: the value '${filePath}' was not found. Skipping this path.`) } - return false + // Continue processing - don't return false here } } + // Update the program options to only include valid paths + if (optionPaths.length > 0) { + program.setOptionValue('paths', validPaths) + } + // rules should only contain existing, correctly spelled rules const allRulesList = [...allRules.map((rule) => rule.names).flat(), ...Object.keys(allConfig)] const optionRules = program.opts().rules || [] @@ -823,7 +833,9 @@ function isOptionsValid() { return false } } - return true + + // Only return false if paths were specified but none are valid + return optionPaths.length === 0 || validPaths.length > 0 } function isAFixtureMdFile(filePath: string): boolean {