Improve key names validation from user' nuget config #187
Improve key names validation from user' nuget config
This commit is contained in:
commit
23fa2c1473
|
@ -4847,6 +4847,9 @@ function configAuthentication(feedUrl, existingFileLocation = '', processRoot =
|
||||||
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
||||||
}
|
}
|
||||||
exports.configAuthentication = configAuthentication;
|
exports.configAuthentication = configAuthentication;
|
||||||
|
function isValidKey(key) {
|
||||||
|
return /^[\w\-\.]+$/i.test(key);
|
||||||
|
}
|
||||||
function getExistingNugetConfig(processRoot) {
|
function getExistingNugetConfig(processRoot) {
|
||||||
const defaultConfigName = 'nuget.config';
|
const defaultConfigName = 'nuget.config';
|
||||||
const configFileNames = fs
|
const configFileNames = fs
|
||||||
|
@ -4922,8 +4925,8 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
||||||
}
|
}
|
||||||
xml = xml.ele('packageSourceCredentials');
|
xml = xml.ele('packageSourceCredentials');
|
||||||
sourceKeys.forEach(key => {
|
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.");
|
throw new Error("Source name can contain letters, numbers, and '-', '_', '.' symbols only. Please, fix source name in NuGet.config and try again.");
|
||||||
}
|
}
|
||||||
xml = xml
|
xml = xml
|
||||||
.ele(key)
|
.ele(key)
|
||||||
|
|
|
@ -27,6 +27,10 @@ export function configAuthentication(
|
||||||
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidKey(key: string): boolean {
|
||||||
|
return /^[\w\-\.]+$/i.test(key);
|
||||||
|
}
|
||||||
|
|
||||||
function getExistingNugetConfig(processRoot: string) {
|
function getExistingNugetConfig(processRoot: string) {
|
||||||
const defaultConfigName = 'nuget.config';
|
const defaultConfigName = 'nuget.config';
|
||||||
const configFileNames = fs
|
const configFileNames = fs
|
||||||
|
@ -122,9 +126,9 @@ function writeFeedToFile(
|
||||||
xml = xml.ele('packageSourceCredentials');
|
xml = xml.ele('packageSourceCredentials');
|
||||||
|
|
||||||
sourceKeys.forEach(key => {
|
sourceKeys.forEach(key => {
|
||||||
if (key.indexOf(' ') > -1) {
|
if (!isValidKey(key)) {
|
||||||
throw new Error(
|
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."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue