Improve package URL validation and skip components with invalid URLs
This commit is contained in:
+27
-1
@@ -82,10 +82,18 @@ export default class ComponentDetection {
|
|||||||
name: component.component.name || 'unnamed',
|
name: component.component.name || 'unnamed',
|
||||||
type: component.component.type || 'unknown'
|
type: component.component.type || 'unknown'
|
||||||
}, null, 2)}`);
|
}, null, 2)}`);
|
||||||
|
// Skip components without packageUrl
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl);
|
const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl);
|
||||||
|
|
||||||
|
// Skip if the packageUrl is empty (indicates an invalid or missing packageUrl)
|
||||||
|
if (!packageUrl) {
|
||||||
|
core.debug(`Skipping component with invalid packageUrl: ${component.component.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!packageCache.hasPackage(packageUrl)) {
|
if (!packageCache.hasPackage(packageUrl)) {
|
||||||
const pkg = new ComponentDetectionPackage(packageUrl, component.component.id,
|
const pkg = new ComponentDetectionPackage(packageUrl, component.component.id,
|
||||||
component.isDevelopmentDependency, component.topLevelReferrers, component.locationsFoundAt, component.containerDetailIds, component.containerLayerIds);
|
component.isDevelopmentDependency, component.topLevelReferrers, component.locationsFoundAt, component.containerDetailIds, component.containerLayerIds);
|
||||||
@@ -98,10 +106,28 @@ export default class ComponentDetection {
|
|||||||
core.debug("Sorting out transitive dependencies");
|
core.debug("Sorting out transitive dependencies");
|
||||||
packages.forEach(async (pkg: ComponentDetectionPackage) => {
|
packages.forEach(async (pkg: ComponentDetectionPackage) => {
|
||||||
pkg.topLevelReferrers.forEach(async (referrer: any) => {
|
pkg.topLevelReferrers.forEach(async (referrer: any) => {
|
||||||
const referrerPackage = packageCache.lookupPackage(ComponentDetection.makePackageUrl(referrer.packageUrl));
|
// Skip if referrer doesn't have a valid packageUrl
|
||||||
|
if (!referrer.packageUrl) {
|
||||||
|
core.debug(`Skipping referrer without packageUrl for component: ${pkg.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const referrerUrl = ComponentDetection.makePackageUrl(referrer.packageUrl);
|
||||||
|
|
||||||
|
// Skip if the generated packageUrl is empty
|
||||||
|
if (!referrerUrl) {
|
||||||
|
core.debug(`Skipping referrer with invalid packageUrl for component: ${pkg.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const referrerPackage = packageCache.lookupPackage(referrerUrl);
|
||||||
if (referrerPackage) {
|
if (referrerPackage) {
|
||||||
referrerPackage.dependsOn(pkg);
|
referrerPackage.dependsOn(pkg);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.debug(`Error looking up referrer package: ${error}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+24
-1
@@ -36177,8 +36177,15 @@ class ComponentDetection {
|
|||||||
name: component.component.name || 'unnamed',
|
name: component.component.name || 'unnamed',
|
||||||
type: component.component.type || 'unknown'
|
type: component.component.type || 'unknown'
|
||||||
}, null, 2)}`);
|
}, null, 2)}`);
|
||||||
|
// Skip components without packageUrl
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl);
|
const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl);
|
||||||
|
// Skip if the packageUrl is empty (indicates an invalid or missing packageUrl)
|
||||||
|
if (!packageUrl) {
|
||||||
|
core.debug(`Skipping component with invalid packageUrl: ${component.component.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!packageCache.hasPackage(packageUrl)) {
|
if (!packageCache.hasPackage(packageUrl)) {
|
||||||
const pkg = new ComponentDetectionPackage(packageUrl, component.component.id, component.isDevelopmentDependency, component.topLevelReferrers, component.locationsFoundAt, component.containerDetailIds, component.containerLayerIds);
|
const pkg = new ComponentDetectionPackage(packageUrl, component.component.id, component.isDevelopmentDependency, component.topLevelReferrers, component.locationsFoundAt, component.containerDetailIds, component.containerLayerIds);
|
||||||
packageCache.addPackage(pkg);
|
packageCache.addPackage(pkg);
|
||||||
@@ -36189,10 +36196,26 @@ class ComponentDetection {
|
|||||||
core.debug("Sorting out transitive dependencies");
|
core.debug("Sorting out transitive dependencies");
|
||||||
packages.forEach((pkg) => __awaiter(this, void 0, void 0, function* () {
|
packages.forEach((pkg) => __awaiter(this, void 0, void 0, function* () {
|
||||||
pkg.topLevelReferrers.forEach((referrer) => __awaiter(this, void 0, void 0, function* () {
|
pkg.topLevelReferrers.forEach((referrer) => __awaiter(this, void 0, void 0, function* () {
|
||||||
const referrerPackage = packageCache.lookupPackage(ComponentDetection.makePackageUrl(referrer.packageUrl));
|
// Skip if referrer doesn't have a valid packageUrl
|
||||||
|
if (!referrer.packageUrl) {
|
||||||
|
core.debug(`Skipping referrer without packageUrl for component: ${pkg.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const referrerUrl = ComponentDetection.makePackageUrl(referrer.packageUrl);
|
||||||
|
// Skip if the generated packageUrl is empty
|
||||||
|
if (!referrerUrl) {
|
||||||
|
core.debug(`Skipping referrer with invalid packageUrl for component: ${pkg.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const referrerPackage = packageCache.lookupPackage(referrerUrl);
|
||||||
if (referrerPackage) {
|
if (referrerPackage) {
|
||||||
referrerPackage.dependsOn(pkg);
|
referrerPackage.dependsOn(pkg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.debug(`Error looking up referrer package: ${error}`);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
// Create manifests
|
// Create manifests
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user