Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force redact all & Redact by Default #41

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const defaultConfig = {
logResponseHeaders: true,
logResponseBody: true,
ignoredDomains: [],
forceRedactAll: false,
redactByDefault: false,
allowedDomains: [],
cacheTtl: 0,

// After the close command is sent, wait for this many milliseconds before
// exiting. This gives any hanging responses a chance to return.
Expand All @@ -38,6 +42,16 @@ const errors = {
'No Client Secret Provided, set SUPERGOOD_CLIENT_SECRET or pass it as an argument'
};

const SensitiveKeyActions = {
REDACT: 'REDACT',
ALLOW: 'ALLOW'
};

const EndpointActions = {
ALLOW: 'Allow',
IGNORE: 'Ignore'
}

const TestErrorPath = '/api/supergood-test-error';
const LocalClientId = 'local-client-id';
const LocalClientSecret = 'local-client-secret';
Expand All @@ -47,5 +61,7 @@ export {
errors,
TestErrorPath,
LocalClientId,
LocalClientSecret
LocalClientSecret,
SensitiveKeyActions,
EndpointActions
};
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const Supergood = () => {

const responseArray = prepareData(
responseCacheValues as EventRequestType[],
supergoodConfig.remoteConfig,
supergoodConfig,
) as Array<EventRequestType>;

let data = [...responseArray];
Expand All @@ -310,7 +310,7 @@ const Supergood = () => {
if (force) {
const requestArray = prepareData(
requestCacheValues as EventRequestType[],
supergoodConfig.remoteConfig
supergoodConfig
) as Array<EventRequestType>;
data = [...requestArray, ...responseArray];
}
Expand Down
17 changes: 10 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ interface ConfigType {
allowedDomains: string[];
allowLocalUrls: boolean;
allowIpAddresses: boolean;
cacheTtl: number;
keysToHash: string[];
remoteConfigFetchEndpoint: string; // Defaults to {baseUrl}/config if not provided
eventSinkEndpoint: string; // Defaults to {baseUrl}/events if not provided
errorSinkEndpoint: string; // Defaults to {baseUrl}/errors if not provided
Expand All @@ -57,6 +55,8 @@ interface ConfigType {
logRequestBody: boolean;
logResponseHeaders: boolean;
logResponseBody: boolean;
forceRedactAll: boolean;
redactByDefault: boolean;
}

interface TelemetryType {
Expand All @@ -69,7 +69,7 @@ interface EndpointConfigType {
location: string;
regex: string;
ignored: boolean;
sensitiveKeys: Array<string>;
sensitiveKeys: Array<{ keyPath: string, action: string }>;
}

interface RemoteConfigType {
Expand All @@ -85,19 +85,20 @@ interface MetadataType {
serviceName?: string;
}

type TagType = Record<string, string | number | string[]>;

interface EventRequestType {
request: RequestType;
response: ResponseType;
tags?: Record<string, string | number | string[]>;
tags?: TagType;
metadata?: {
sensitiveKeys: Array<SensitiveKeyMetadata>;
tags?: Record<string, string | number | string[]>;
tags?: TagType;
};
}

type SupergoodContext = {
tags: Record<string, string | number | string[]>;
tags: TagType;
};

// interface EventResponseType {}
Expand Down Expand Up @@ -147,6 +148,7 @@ type RemoteConfigPayloadType = Array<{
sensitiveKeys: Array<
{
keyPath: string;
action: string;
}>;
}
}>;
Expand Down Expand Up @@ -174,5 +176,6 @@ export type {
RemoteConfigPayloadType,
MetadataType,
TelemetryType,
SupergoodContext
SupergoodContext,
TagType
};
Loading
Loading