Skip to content

Commit 60ced10

Browse files
authored
Merge pull request #41343 from github/repo-sync
Repo sync
2 parents ece3a5e + a616253 commit 60ced10

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

content/code-security/secret-scanning/managing-alerts-from-secret-scanning/resolving-alerts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Resolving alerts from secret scanning
33
intro: 'After reviewing the details of a secret scanning alert, you should fix and then close the alert.'
4-
permissions: 'Repository owners, organization owners, security managers, commit authors, and users with the **admin** role'
4+
permissions: 'Repository owners, organization owners, security managers, users assigned to {% data variables.secret-scanning.alerts %}, commit authors, and users with the **admin** role'
55
versions:
66
fpt: '*'
77
ghes: '*'

src/content-linter/scripts/lint-content.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ program
127127

128128
const {
129129
fix,
130-
paths,
131130
errorsOnly,
132131
rules,
133132
summaryByRule,
@@ -144,8 +143,13 @@ main()
144143
async function main() {
145144
if (!isOptionsValid()) return
146145

146+
// Get the updated paths after validation (invalid paths will have been filtered out)
147+
const validatedPaths = program.opts().paths
148+
147149
// If paths has not been specified, lint all files
148-
const files = getFilesToLint((summaryByRule && ALL_CONTENT_DIR) || paths || getChangedFiles())
150+
const files = getFilesToLint(
151+
(summaryByRule && ALL_CONTENT_DIR) || validatedPaths || getChangedFiles(),
152+
)
149153

150154
if (new Set(files.data).size !== files.data.length) throw new Error('Duplicate data files')
151155
if (new Set(files.content).size !== files.content.length)
@@ -162,7 +166,7 @@ async function main() {
162166
const start = Date.now()
163167

164168
// Initializes the config to pass to markdownlint based on the input options
165-
const { config, configuredRules } = getMarkdownLintConfig(errorsOnly, rules || [])
169+
const { config, configuredRules } = getMarkdownLintConfig(errorsOnly, rules)
166170

167171
// Run Markdownlint for content directory
168172
const resultContent = (await markdownlint.promises.markdownlint({
@@ -619,7 +623,7 @@ function listRules() {
619623
*/
620624
function getMarkdownLintConfig(
621625
filterErrorsOnly: boolean,
622-
runRules: string[],
626+
runRules: string[] | undefined,
623627
): MarkdownLintConfigResult {
624628
const config = {
625629
content: structuredClone(defaultConfig),
@@ -793,21 +797,27 @@ function getSearchReplaceRuleSeverity(
793797
function isOptionsValid() {
794798
// paths should only contain existing files and directories
795799
const optionPaths = program.opts().paths || []
800+
const validPaths = []
801+
796802
for (const filePath of optionPaths) {
797803
try {
798804
fs.statSync(filePath)
805+
validPaths.push(filePath) // Keep track of valid paths
799806
} catch {
800807
if ('paths'.includes(filePath)) {
801-
console.log('error: did you mean --paths')
808+
console.warn('warning: did you mean --paths')
802809
} else {
803-
console.log(
804-
`error: invalid --paths (-p) option. The value '${filePath}' is not a valid file or directory`,
805-
)
810+
console.warn(`warning: the value '${filePath}' was not found. Skipping this path.`)
806811
}
807-
return false
812+
// Continue processing - don't return false here
808813
}
809814
}
810815

816+
// Update the program options to only include valid paths
817+
if (optionPaths.length > 0) {
818+
program.setOptionValue('paths', validPaths)
819+
}
820+
811821
// rules should only contain existing, correctly spelled rules
812822
const allRulesList = [...allRules.map((rule) => rule.names).flat(), ...Object.keys(allConfig)]
813823
const optionRules = program.opts().rules || []
@@ -823,7 +833,9 @@ function isOptionsValid() {
823833
return false
824834
}
825835
}
826-
return true
836+
837+
// Only return false if paths were specified but none are valid
838+
return optionPaths.length === 0 || validPaths.length > 0
827839
}
828840

829841
function isAFixtureMdFile(filePath: string): boolean {

0 commit comments

Comments
 (0)