mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-24 14:34:21 +00:00
f911008ea4
* feat(presets): add PHP2Shell security updates Amp-Thread-ID: https://ampcode.com/threads/T-01a1601f-c5b2-745d-bc92-275ec139e3af * Apply batched suggestions from code review Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com> * fix(presets): preserve normal PHP update policies Amp-Thread-ID: https://ampcode.com/threads/T-01a1601f-c5b2-745d-bc92-275ec139e3af * refactor(presets): clarify PHP2Shell version checks Amp-Thread-ID: https://ampcode.com/threads/T-01a1601f-c5b2-745d-bc92-275ec139e3af * fix(presets): mark PHP2Shell fixes as security updates Amp-Thread-ID: https://ampcode.com/threads/T-01a1601f-c5b2-745d-bc92-275ec139e3af * fix(config): avoid adding absent vulnerability severity Amp-Thread-ID: https://ampcode.com/threads/T-01a1601f-c5b2-745d-bc92-275ec139e3af
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import { instrument } from '../instrumentation/index.ts';
|
|
import { logger } from '../logger/index.ts';
|
|
import { clone } from '../util/clone.ts';
|
|
import { getHighestVulnerabilitySeverity } from '../util/vulnerability/utils.ts';
|
|
import * as options from './options/index.ts';
|
|
import type { RenovateConfig } from './types.ts';
|
|
|
|
export function mergeChildConfig<
|
|
T extends Record<string, any>,
|
|
TChild extends Record<string, any> | undefined,
|
|
>(parent: T, child: TChild): T & TChild {
|
|
return instrument('mergeChildConfig', () => {
|
|
logger.trace({ parent, child }, `mergeChildConfig`);
|
|
if (!child) {
|
|
return parent as never;
|
|
}
|
|
const parentConfig = clone(parent);
|
|
const childConfig = clone(child);
|
|
const config: Record<string, any> = { ...parentConfig, ...childConfig };
|
|
|
|
// Ensure highest severity survives parent / child merge
|
|
if (
|
|
config.isVulnerabilityAlert &&
|
|
(parent.vulnerabilitySeverity !== undefined ||
|
|
child.vulnerabilitySeverity !== undefined)
|
|
) {
|
|
config.vulnerabilitySeverity = getHighestVulnerabilitySeverity(
|
|
parent,
|
|
child,
|
|
);
|
|
}
|
|
|
|
for (const option of options.getOptions()) {
|
|
if (
|
|
option.mergeable &&
|
|
childConfig[option.name] &&
|
|
parentConfig[option.name]
|
|
) {
|
|
logger.trace(`mergeable option: ${option.name}`);
|
|
|
|
if (option.name === 'constraints') {
|
|
config[option.name] = {
|
|
...parentConfig[option.name],
|
|
...childConfig[option.name],
|
|
};
|
|
} else if (option.type === 'array') {
|
|
config[option.name] = (parentConfig[option.name] as unknown[]).concat(
|
|
config[option.name],
|
|
);
|
|
} else {
|
|
config[option.name] = mergeChildConfig(
|
|
parentConfig[option.name] as RenovateConfig,
|
|
childConfig[option.name] as RenovateConfig,
|
|
);
|
|
}
|
|
logger.trace(
|
|
{ result: config[option.name] },
|
|
`Merged config.${option.name}`,
|
|
);
|
|
}
|
|
}
|
|
return { ...config, ...config.force };
|
|
});
|
|
}
|