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

Fixes 1264 #1266

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ export async function createJavaBom(path, options) {
let bomJsonFiles = [];
if (
pomFiles?.length &&
!options.projectType?.includes("bazel") &&
!options.projectType?.includes("scala") &&
!options.projectType?.includes("sbt") &&
!options.projectType?.includes("gradle")
Expand Down Expand Up @@ -1612,6 +1613,8 @@ export async function createJavaBom(path, options) {
// Execute gradle properties
if (
gradleFiles?.length &&
!options.projectType?.includes("maven") &&
!options.projectType?.includes("bazel") &&
!options.projectType?.includes("scala") &&
!options.projectType?.includes("sbt")
) {
Expand Down Expand Up @@ -1744,6 +1747,8 @@ export async function createJavaBom(path, options) {
if (
gradleFiles?.length &&
options.installDeps &&
!options.projectType?.includes("maven") &&
!options.projectType?.includes("bazel") &&
!options.projectType?.includes("scala") &&
!options.projectType?.includes("sbt")
) {
Expand Down Expand Up @@ -1939,6 +1944,8 @@ export async function createJavaBom(path, options) {
const bazelFiles = getAllFiles(path, "BUILD", options);
if (
bazelFiles?.length &&
!options.projectType?.includes("maven") &&
!options.projectType?.includes("gradle") &&
!options.projectType?.includes("scala") &&
!options.projectType?.includes("sbt")
) {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts.map

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

2 changes: 1 addition & 1 deletion types/utils.d.ts.map

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

21 changes: 14 additions & 7 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3182,12 +3182,15 @@ export async function getMvnMetadata(pkgList, jarNSMapping = {}) {
try {
if (DEBUG_MODE) {
console.log(
`Querying ${pomMetadata.urlPrefix} from ${composePomXmlUrl(
`Querying ${pomMetadata.urlPrefix} for '${group}/${p.name}@${p.version}' ${composePomXmlUrl(
pomMetadata,
)}`,
);
}
const bodyJson = await fetchPomXmlAsJson(pomMetadata);
if (!bodyJson) {
continue;
}
p.publisher = bodyJson.organization?.name
? bodyJson.organization.name._
: "";
Expand Down Expand Up @@ -3243,6 +3246,9 @@ export function composePomXmlUrl({ urlPrefix, group, name, version }) {
*/
export async function fetchPomXmlAsJson({ urlPrefix, group, name, version }) {
const pomXml = await fetchPomXml({ urlPrefix, group, name, version });
if (!pomXml) {
return undefined;
}
const options = {
compact: true,
spaces: 4,
Expand All @@ -3258,6 +3264,9 @@ export async function fetchPomXmlAsJson({ urlPrefix, group, name, version }) {
name: pomJson.parent.artifactId?._,
version: pomJson.parent.version?._,
});
if (!parentXml) {
return undefined;
}
const parentJson = xml2js(parentXml, options).project;
const result = { ...parentJson, ...pomJson };
return result;
Expand Down Expand Up @@ -11208,6 +11217,10 @@ export function parseMakeDFile(dfile) {
*/
export function isValidIriReference(iri) {
let iriIsValid = true;
// See issue #1264
if (iri && /[${}]/.test(iri)) {
return false;
}
const validateIriResult = validateIri(iri, IriValidationStrategy.Strict);

if (validateIriResult instanceof Error) {
Expand All @@ -11219,14 +11232,8 @@ export function isValidIriReference(iri) {
iriIsValid = false;
}
}

if (iriIsValid) {
return true;
}

if (DEBUG_MODE) {
console.log(`IRI failed validation ${iri}`);
}

return false;
}
2 changes: 2 additions & 0 deletions utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,8 @@ test.each([
["https://", false],
["http://www", true],
["http://www.", true],
["https://github.com/apache/maven-resolver/tree/${project.scm.tag}", false],
["[email protected]:prometheus/client_java.git", false],
])("isValidIriReference tests: %s", (url, isValid) => {
expect(isValidIriReference(url)).toBe(isValid);
});
Expand Down
Loading