Skip to content

Commit

Permalink
fix(kustomize): validate name is a string (#24676)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
rarkins and viceice committed Sep 27, 2023
1 parent 8bdcfd5 commit a6c9075
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/modules/manager/kustomize/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ describe('modules/manager/kustomize/extract', () => {
expect(pkg).toBeNull();
});

it('should return null on invalid input', () => {
const pkg = extractImage({
// @ts-expect-error: for testing
name: 3,
newTag: '',
});
expect(pkg).toBeNull();
});

it('should correctly extract a default image', () => {
const sample = {
currentDigest: undefined,
Expand Down
7 changes: 6 additions & 1 deletion lib/modules/manager/kustomize/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export function extractImage(image: Image): PackageDependency | null {
if (!image.name) {
return null;
}
const nameDep = splitImageParts(image.newName ?? image.name);
const nameToSplit = image.newName ?? image.name;
if (!is.string(nameToSplit)) {
logger.debug({ image }, 'Invalid image name');
return null;
}
const nameDep = splitImageParts(nameToSplit);
const { depName } = nameDep;
const { digest, newTag } = image;
if (digest && newTag) {
Expand Down

0 comments on commit a6c9075

Please sign in to comment.