fix(manager/terraform): Guard against empty module and provider fields (#20394)

This commit is contained in:
Sergei Zharinov 2023-02-14 12:39:09 +03:00 committed by GitHub
parent 2235659b18
commit 3eb96c9647
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View file

@ -34,6 +34,12 @@ export class ModuleExtractor extends DependencyExtractor {
return [];
}
// istanbul ignore if
if (!is.plainObject(modules)) {
logger.debug({ modules }, 'Terraform: unexpected `modules` value');
return [];
}
const dependencies = [];
for (const moduleElement of Object.values(modules).flat()) {
const dep = {

View file

@ -1,4 +1,5 @@
import is from '@sindresorhus/is';
import { logger } from '../../../../../logger';
import type { PackageDependency } from '../../../types';
import { TerraformProviderExtractor } from '../../base';
import type { TerraformDefinitionFile } from '../../hcl/types';
@ -18,6 +19,15 @@ export class ProvidersExtractor extends TerraformProviderExtractor {
return [];
}
// istanbul ignore if
if (!is.plainObject(providerTypes)) {
logger.debug(
{ providerTypes },
'Terraform: unexpected `providerTypes` value'
);
return [];
}
const dependencies = [];
for (const providerTypeName of Object.keys(providerTypes)) {
for (const providerTypeElement of providerTypes[providerTypeName]) {

View file

@ -1,4 +1,5 @@
import is from '@sindresorhus/is';
import { logger } from '../../../../../logger';
import { DockerDatasource } from '../../../../datasource/docker';
import { HelmDatasource } from '../../../../datasource/helm';
import { isOCIRegistry } from '../../../helmv3/utils';
@ -19,6 +20,16 @@ export class HelmReleaseExtractor extends DependencyExtractor {
if (is.nullOrUndefined(helmReleases)) {
return [];
}
// istanbul ignore if
if (!is.plainObject(helmReleases)) {
logger.debug(
{ helmReleases },
'Terraform: unexpected `helmReleases` value'
);
return [];
}
for (const helmRelease of Object.values(helmReleases).flat()) {
const dep: PackageDependency = {
currentValue: helmRelease.version,