Skip to content

Commit 73e1388

Browse files
committed
Validate packageUrlJson structure in makePackageUrl method
1 parent 47ec470 commit 73e1388

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

componentDetection.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,13 @@ export default class ComponentDetection {
156156

157157
public static makePackageUrl(packageUrlJson: any): string {
158158
// Handle case when packageUrlJson is null or undefined
159-
if (!packageUrlJson) {
159+
if (
160+
!packageUrlJson ||
161+
typeof packageUrlJson.Scheme !== 'string' ||
162+
typeof packageUrlJson.Type !== 'string' ||
163+
!packageUrlJson.Scheme ||
164+
!packageUrlJson.Type
165+
) {
160166
core.debug(`Warning: Received null or undefined packageUrlJson. Unable to create package URL.`);
161167
return ""; // Return a blank string for unknown packages
162168
}

dist/index.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)