Skip to content

Commit

Permalink
fix(kibana-security-health-check): track only selected injected metad…
Browse files Browse the repository at this point in the history
…ata fields
  • Loading branch information
azasypkin committed Dec 9, 2023
1 parent 292389a commit 35c8a70
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kibana-security-health-check/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const TRACKED_RESPONSE_HEADERS = [
'x-frame-options',
];

const TRACKED_INJECTED_METADATA = ['anonymousStatusPage', 'clusterInfo', 'csp', 'env', 'externalUrl'];

export async function run(
previousContent: State | undefined,
remoteResources: WebPageResource[],
Expand All @@ -47,6 +49,7 @@ export async function run(
const injectedMetadata = JSON.parse(
dom.querySelector('kbn-injected-metadata')?.getAttribute('data') ?? '{}',
) as Record<string, unknown>;

return {
headers: Object.fromEntries(
Object.entries(responseHeaders).filter(([key]) => TRACKED_RESPONSE_HEADERS.includes(key.toLowerCase())),
Expand All @@ -59,7 +62,9 @@ export async function run(
3,
),
},
injectedMetadata,
injectedMetadata: Object.fromEntries(
Object.entries(injectedMetadata).filter(([key]) => TRACKED_INJECTED_METADATA.includes(key)),
),
};
}
function formatBytes(bytes: number, decimals: number) {
Expand Down

0 comments on commit 35c8a70

Please sign in to comment.