Skip to content

Commit

Permalink
Showing 6 changed files with 25 additions and 22 deletions.
10 changes: 9 additions & 1 deletion lib/analysis-paths.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analysis-paths.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions lib/config-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.js.map

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/analysis-paths.ts
@@ -6,9 +6,20 @@ function isInterpretedLanguage(language): boolean {
return language === 'javascript' || language === 'python';
}

// Matches a string containing only characters that are legal to include in paths on windows.
export const legalWindowsPathCharactersRegex = /^[^<>:"\|?]*$/;

// Builds an environment variable suitable for LGTM_INDEX_INCLUDE or LGTM_INDEX_EXCLUDE
function buildIncludeExcludeEnvVar(paths: string[]): string {
return paths.filter(p => p.indexOf('**') === -1).join('\n');
// Ignore anything containing a *
paths = paths.filter(p => p.indexOf('*') === -1);

// Some characters are illegal in path names in windows
if (process.platform === 'win32') {
paths = paths.filter(p => p.match(legalWindowsPathCharactersRegex));
}

return paths.join('\n');
}

export function includeAndExcludeAnalysisPaths(config: configUtils.Config, languages: string[]) {
11 changes: 1 addition & 10 deletions src/config-utils.ts
@@ -122,9 +122,6 @@ const pathStarsRegex = /.*(?:\*\*[^/].*|\*\*$|[^/]\*\*.*)/;
// See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
const filterPatternCharactersRegex = /.*[\?\+\[\]!].*/;

// Matches any string containing characters that are illegal to include in paths on windows.
export const illegalWindowsCharactersRegex = /.*[<>:"\|?*].*/;

// Checks that a paths of paths-ignore entry is valid, possibly modifying it
// to make it valid, or if not possible then throws an error.
export function validateAndSanitisePath(
@@ -161,13 +158,7 @@ export function validateAndSanitisePath(
configFile,
propertyName,
'"' + originalPath + '" contains an unsupported character. ' +
'The filter pattern characteres ?, +, [, ], ! are not supported and will be matched literally.'));
}

// Check for any characters that are illegal in path names in windows
if (process.platform === 'win32' && path.match(illegalWindowsCharactersRegex)) {
throw new Error('"' + path + '" contains an invalid character. ' +
'The characteres <, >, :, ", !, |, ?, * are forbidden to use in paths on windows.');
'The filter pattern characters ?, +, [, ], ! are not supported and will be matched literally.'));
}

return path;

0 comments on commit 24367a8

Please sign in to comment.