mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-28 08:49:38 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
50
packages/context/src/scan/credentials.ts
Normal file
50
packages/context/src/scan/credentials.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import {
|
||||
redactKloSensitiveMetadata,
|
||||
redactKloSensitiveText,
|
||||
redactKloSensitiveValue,
|
||||
REDACTED_KLO_CREDENTIAL_VALUE,
|
||||
} from '../core/redaction.js';
|
||||
import type { KloCredentialEnvelope, KloScanReport, KloScanWarning } from './types.js';
|
||||
|
||||
export { REDACTED_KLO_CREDENTIAL_VALUE };
|
||||
|
||||
export function redactKloCredentialValue(key: string, value: unknown): unknown {
|
||||
return redactKloSensitiveValue(key, value);
|
||||
}
|
||||
|
||||
export function redactKloScanMetadata(metadata: Record<string, unknown>): Record<string, unknown> {
|
||||
return redactKloSensitiveMetadata(metadata);
|
||||
}
|
||||
|
||||
export function redactKloCredentialEnvelope(envelope: KloCredentialEnvelope): KloCredentialEnvelope {
|
||||
if (envelope.kind !== 'resolved') {
|
||||
return envelope;
|
||||
}
|
||||
return {
|
||||
kind: 'resolved',
|
||||
source: envelope.source,
|
||||
redacted: true,
|
||||
values: redactKloScanMetadata(envelope.values),
|
||||
};
|
||||
}
|
||||
|
||||
export function redactKloScanWarning(warning: KloScanWarning): KloScanWarning {
|
||||
if (!warning.metadata) {
|
||||
return {
|
||||
...warning,
|
||||
message: redactKloSensitiveText(warning.message),
|
||||
};
|
||||
}
|
||||
return {
|
||||
...warning,
|
||||
message: redactKloSensitiveText(warning.message),
|
||||
metadata: redactKloScanMetadata(warning.metadata),
|
||||
};
|
||||
}
|
||||
|
||||
export function redactKloScanReport(report: KloScanReport): KloScanReport {
|
||||
return {
|
||||
...report,
|
||||
warnings: report.warnings.map((warning) => redactKloScanWarning(warning)),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue