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

DXCDT-383: Integrate preserveKeywords function into export process #751

Merged
10 changes: 8 additions & 2 deletions src/context/directory/handlers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ function parse(context: DirectoryContext): ParsedActions {

const files = getFiles(actionsFolder, ['.json']);
const actions = files.map((file) => {
const action = { ...loadJSON(file, context.mappings) };
const action = {
...loadJSON(file, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
const actionFolder = path.join(constants.ACTIONS_DIRECTORY, `${action.name}`);

if (action.code) {
const toUnixPath = somePath => somePath.replace(/[\\/]+/g, '/').replace(/^([a-zA-Z]+:|\.\/)/, '');
const toUnixPath = (somePath) =>
somePath.replace(/[\\/]+/g, '/').replace(/^([a-zA-Z]+:|\.\/)/, '');
action.code = context.loadFile(toUnixPath(action.code), actionFolder);
}

Expand Down
15 changes: 12 additions & 3 deletions src/context/directory/handlers/attackProtection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ function parse(context: DirectoryContext): ParsedAttackProtection {
};
}

const breachedPasswordDetection = loadJSON(files.breachedPasswordDetection, context.mappings);
const bruteForceProtection = loadJSON(files.bruteForceProtection, context.mappings);
const suspiciousIpThrottling = loadJSON(files.suspiciousIpThrottling, context.mappings);
const breachedPasswordDetection = loadJSON(files.breachedPasswordDetection, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});
const bruteForceProtection = loadJSON(files.bruteForceProtection, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});
const suspiciousIpThrottling = loadJSON(files.suspiciousIpThrottling, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});

return {
attackProtection: {
Expand Down
10 changes: 8 additions & 2 deletions src/context/directory/handlers/branding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function parse(context: DirectoryContext): ParsedBranding {

const brandingSettings = (() => {
if (isFile(brandingFile)) {
return loadJSON(brandingFile, context.mappings);
return loadJSON(brandingFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});
}

return null;
Expand All @@ -31,7 +34,10 @@ function parse(context: DirectoryContext): ParsedBranding {

const templatesDefinitionFiles = getFiles(brandingTemplatesFolder, ['.json']);
const templates = templatesDefinitionFiles.map((templateDefinitionFile) => {
const definition = loadJSON(templateDefinitionFile, context.mappings);
const definition = loadJSON(templateDefinitionFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});
definition.body = loadFileAndReplaceKeywords(
path.join(brandingTemplatesFolder, definition.body),
context.mappings
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/clientGrants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ function parse(context: DirectoryContext): ParsedClientGrants {
const foundFiles = getFiles(grantsFolder, ['.json']);

const clientGrants = foundFiles
.map((f) => loadJSON(f, context.mappings))
.map((f) =>
loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
})
)
.filter((p) => Object.keys(p).length > 0); // Filter out empty grants

return {
Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ function parse(context: DirectoryContext): ParsedClients {

const clients = foundFiles
.map((f) => {
const client = loadJSON(f, context.mappings);
const client = loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});

if (client.custom_login_page) {
const htmlFileName = path.join(clientsFolder, client.custom_login_page);
Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ function parse(context: DirectoryContext): ParsedConnections {

const connections = foundFiles
.map((f) => {
const connection = loadJSON(f, context.mappings);
const connection = loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});

if (connection.strategy === 'email') {
ensureProp(connection, 'options.email.body');
Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/customDomains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function parse(context: DirectoryContext): ParsedCustomDomains {
const customDomainsFile = getCustomDomainsFile(context.filePath);

return {
customDomains: loadJSON(customDomainsFile, context.mappings),
customDomains: loadJSON(customDomainsFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
}

Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/emailProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ function parse(context: DirectoryContext): ParsedEmailProvider {

if (isFile(providerFile)) {
return {
emailProvider: loadJSON(providerFile, context.mappings),
emailProvider: loadJSON(providerFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
}

Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/emailTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ function parse(context: DirectoryContext): ParsedEmailTemplates {
return [];
} else {
return {
...loadJSON(meta, context.mappings),
...loadJSON(meta, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
body: loadFileAndReplaceKeywords(html, context.mappings),
};
}
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/guardianFactorProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ function parse(context: DirectoryContext): ParsedGuardianFactorProviders {
const foundFiles = getFiles(factorProvidersFolder, ['.json']);

const guardianFactorProviders = foundFiles
.map((f) => loadJSON(f, context.mappings))
.map((f) =>
loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
})
)
.filter((p) => Object.keys(p).length > 0); // Filter out empty factorProvidersFolder

return {
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/guardianFactorTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ function parse(context: DirectoryContext): ParsedGuardianFactorTemplates {
const foundFiles = getFiles(factorTemplatesFolder, ['.json']);

const guardianFactorTemplates = foundFiles
.map((f) => loadJSON(f, context.mappings))
.map((f) =>
loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
})
)
.filter((p) => Object.keys(p).length > 0); // Filter out empty guardianFactorTemplates

return {
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/guardianFactors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ function parse(context: DirectoryContext): ParsedGuardianFactors {
const foundFiles = getFiles(factorsFolder, ['.json']);

const guardianFactors = foundFiles
.map((f) => loadJSON(f, context.mappings))
.map((f) =>
loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
})
)
.filter((p) => Object.keys(p).length > 0); // Filter out empty guardianFactors

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ function parse(context: DirectoryContext): ParsedGuardianFactorMessageTypes {
}

return {
guardianPhoneFactorMessageTypes: loadJSON(file, context.mappings),
guardianPhoneFactorMessageTypes: loadJSON(file, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function parse(context: DirectoryContext): ParsedGuardianFactorSelectedProvider
}

return {
guardianPhoneFactorSelectedProvider: loadJSON(file, context.mappings),
guardianPhoneFactorSelectedProvider: loadJSON(file, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
}

Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/guardianPolicies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ function parse(context: DirectoryContext): ParsedGuardianPolicies {
}

return {
guardianPolicies: loadJSON(file, context.mappings),
guardianPolicies: loadJSON(file, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
}

Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ function parse(context: DirectoryContext): ParsedHooks {
const files = getFiles(hooksFolder, ['.json']);

const hooks = files.map((f) => {
const hook = { ...loadJSON(f, context.mappings) };
const hook = {
...loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
if (hook.script) {
hook.script = context.loadFile(hook.script, constants.HOOKS_DIRECTORY);
}
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/logStreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ function parse(context: DirectoryContext): ParsedLogStreams {
const foundFiles = getFiles(logStreamsDirectory, ['.json']);

const logStreams = foundFiles
.map((f) => loadJSON(f, context.mappings))
.map((f) =>
loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
})
)
.filter((p) => Object.keys(p).length > 0); // Filter out empty rulesConfigs

return {
Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function parse(context: DirectoryContext): ParsedMigrations {
if (!isFile(migrationsFile)) return { migrations: null };

/* eslint-disable camelcase */
const migrations = loadJSON(migrationsFile, context.mappings);
const migrations = loadJSON(migrationsFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});

return { migrations };
}
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ function parse(context: DirectoryContext): ParsedOrganizations {
const files = getFiles(organizationsFolder, ['.json']);

const organizations = files.map((f) => {
const org = { ...loadJSON(f, context.mappings) };
const org = {
...loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
return org;
});

Expand Down
10 changes: 8 additions & 2 deletions src/context/directory/handlers/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ function parse(context: DirectoryContext): ParsedPages {
if (!html && ['error_page', 'login'].includes(key)) {
//Error pages don't require an HTML template, it is valid to redirect errors to URL
return {
...loadJSON(meta, context.mappings),
...loadJSON(meta, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
html: '',
};
}
Expand All @@ -48,7 +51,10 @@ function parse(context: DirectoryContext): ParsedPages {
return [];
}
return {
...loadJSON(meta, context.mappings),
...loadJSON(meta, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
html: loadFileAndReplaceKeywords(html, context.mappings),
};
});
Expand Down
10 changes: 8 additions & 2 deletions src/context/directory/handlers/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ function parse(context: DirectoryContext): ParsedPrompts {
const promptsSettings = (() => {
const promptsSettingsFile = getPromptsSettingsFile(promptsDirectory);
if (!isFile(promptsSettingsFile)) return {};
return loadJSON(promptsSettingsFile, context.mappings) as PromptSettings;
return loadJSON(promptsSettingsFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}) as PromptSettings;
})();

const customText = (() => {
const customTextFile = getCustomTextFile(promptsDirectory);
if (!isFile(customTextFile)) return {};
return loadJSON(customTextFile, context.mappings) as AllPromptsByLanguage;
return loadJSON(customTextFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}) as AllPromptsByLanguage;
})();

return {
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/resourceServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ function parse(context: DirectoryContext): ParsedResourceServers {
const foundFiles = getFiles(resourceServersFolder, ['.json']);

const resourceServers = foundFiles
.map((f) => loadJSON(f, context.mappings))
.map((f) =>
loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
})
)
.filter((p) => Object.keys(p).length > 0); // Filter out empty resourceServers

return {
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ function parse(context: DirectoryContext): ParsedRoles {
const files = getFiles(rolesFolder, ['.json']);

const roles = files.map((f) => {
const role = { ...loadJSON(f, context.mappings) };
const role = {
...loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
return role;
});

Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ function parse(context: DirectoryContext): ParsedRules {
const files: string[] = getFiles(rulesFolder, ['.json']);

const rules = files.map((f) => {
const rule = { ...loadJSON(f, context.mappings) };
const rule = {
...loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
}),
};
if (rule.script) {
rule.script = context.loadFile(rule.script, constants.RULES_DIRECTORY);
}
Expand Down
7 changes: 6 additions & 1 deletion src/context/directory/handlers/rulesConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ function parse(context: DirectoryContext): ParsedRulesConfigs {
const foundFiles: string[] = getFiles(rulesConfigsFolder, ['.json']);

const rulesConfigs = foundFiles
.map((f) => loadJSON(f, context.mappings))
.map((f) =>
loadJSON(f, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
})
)
.filter((p) => Object.keys(p).length > 0); // Filter out empty rulesConfigs

return {
Expand Down
5 changes: 4 additions & 1 deletion src/context/directory/handlers/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function parse(context: DirectoryContext): ParsedTenant {
session_lifetime?: number;
idle_session_lifetime?: number;
[key: string]: any;
} = loadJSON(tenantFile, context.mappings);
} = loadJSON(tenantFile, {
mappings: context.mappings,
disableKeywordReplacement: context.disableKeywordReplacement,
});

clearTenantFlags(tenant);

Expand Down
Loading