Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve key names validation from user' nuget config #187

Merged
merged 6 commits into from Apr 22, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/authutil.ts
Expand Up @@ -25,6 +25,10 @@ export function configAuthentication(
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
}

function isValidKey(key: string): boolean {
return /^[0-9\w\-\_\.]+$/i.test(key);
vsafonkin marked this conversation as resolved.
Show resolved Hide resolved
}

function writeFeedToFile(
feedUrl: string,
existingFileLocation: string,
Expand Down Expand Up @@ -109,9 +113,9 @@ function writeFeedToFile(
xml = xml.ele('packageSourceCredentials');

sourceKeys.forEach(key => {
if (key.indexOf(' ') > -1) {
if (!isValidKey(key)) {
throw new Error(
"This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."
"Source name can contain letters, numbers, and '-', '_', '.' symbols only, Please, fix source name in NuGet.config and try again."
vsafonkin marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down