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

Add support for the rest of the BoxLang settings #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
39 changes: 38 additions & 1 deletion models/BaseConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,42 @@ component accessors="true" {
property name='allowedFileOperationExtensions' type='array' _isCFConfig=true;
// The BoxLang module settings
property name='modules' type='struct' _isCFConfig=true;
// The BoxLang modules directory array
property name='modulesDirectory' type='array' _isCFConfig=true;
// The Boxlang executors struct
property name='executors' type='struct' _isCFConfig=true;
// A collection of directories we will class load all Java *.jar files from
property name='javaLibraryPaths' type='array' _isCFConfig=true;
// The maximum number of days to keep log files before rotation
// Default is 90 days or 3 months
// Set to 0 to never rotate
property name='loggingMaxLogDays' type='numeric' _isCFConfig=true;
// The total cap size of all log files before rotation
// You can use the following suffixes: KB, MB, GB
// Default is 5GB
property name='loggingTotalCapSize' type='string' _isCFConfig=true;
// The root logger level
// Valid values are in order of severity: ERROR, WARN, INFO, DEBUG, TRACE, OFF
// If the runtime is in Debug mode, this will be set to DEBUG
property name='loggingRootLevel' type='string' _isCFConfig=true;
// Default Encoder for file appenders.
// The available options are "text" and "json"
property name='loggingDefaultEncoder' type='string' _isCFConfig=true;
// Activate the status printer on load to print out the logging configuration
// Turn on to debug LogBack and BoxLang logging configurations
property name='loggingStatusPrinterOnLoad' type='boolean' _isCFConfig=true;
// A collection of pre-defined loggers and their configurations
property name='loggingLoggers' type='struct' _isCFConfig=true;
// A list of regex patterns that will match class paths, and if matched, execution will be disallowed
property name='securityDisallowedImports' type='array' _isCFConfig=true;
// A list of BIF names that will be disallowed from execution
property name='securityDisallowedBifs' type='array' _isCFConfig=true;
// A list of Component names that will be disallowed from execution
property name='securityDisallowedComponents' type='array' _isCFConfig=true;
// An explicit whitelist of file extensions that are allowed to be uploaded - overrides any values in the disallowedWriteExtensions
property name='securityAllowedFileOperationExtensions' type='array' _isCFConfig=true;
// The list of file extensions that are not allowed to be uploaded. Also enforced by file relocation operations ( e.g. copy/move )
property name='securitydisallowedFileOperationExtensions' type='array' _isCFConfig=true;

/**
* Constructor
Expand Down Expand Up @@ -1702,8 +1738,9 @@ component accessors="true" {
'cacheClasses' : 'class',
'validClassExtensions' : '',
'validTemplateExtensions' : '', // break this out, or externalize the mapping information from it
'classPaths' : '',
'disallowedFileOperationExtensions' : '',
'scheduledTasks' : 'name',
'scheduledTasks' : 'name'
};

for( var prop in memento ) {
Expand Down
43 changes: 40 additions & 3 deletions models/providers/BoxLang1.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ component accessors=true extends='cfconfig-services.models.BaseConfig' {

// Convert whitespaceCompressionEnabled to whitespaceManagement
if( configData.keyExists( 'whitespaceCompressionEnabled' ) ) {
configData[ 'whitespaceManagement' ] = translateWhitespaceToBoxLang( configData.whitespaceCompressionEnabled );
configData[ 'whitespaceManagement' ] = translateWhitespaceFromBoxLang( configData.whitespaceCompressionEnabled );
configData.delete( 'whitespaceCompressionEnabled' );
}

Expand All @@ -102,6 +102,12 @@ component accessors=true extends='cfconfig-services.models.BaseConfig' {
configData.delete( 'disallowedFileOperationExtensions' );
}

// Convert classPaths to componentPaths
if( configData.keyExists( 'classPaths' ) ) {
configData[ 'componentPaths' ] = classPathsToComponentPaths( configData.classPaths );
configData.delete( 'classPaths' );
}

if ( configData.keyExists( 'logging' )) {
// Convert logsDirectory to logDirectory
if( configData.logging.keyExists( 'logsDirectory' ) ) {
Expand Down Expand Up @@ -201,7 +207,7 @@ component accessors=true extends='cfconfig-services.models.BaseConfig' {

// Convert whitespaceCompressionEnabled to whitespaceCompressionEnabled
if( configData.keyExists( 'whitespaceManagement' ) ) {
configData[ 'whitespaceCompressionEnabled' ] = translateWhitespaceFromBoxLang( configData.whitespaceManagement );
configData[ 'whitespaceCompressionEnabled' ] = translateWhitespaceToBoxLang( configData.whitespaceManagement );
configData.delete( 'whitespaceManagement' );
}

Expand All @@ -211,12 +217,18 @@ component accessors=true extends='cfconfig-services.models.BaseConfig' {
configData.delete( 'blockedExtForFileUpload' );
}

// Convert componentPaths to classPaths
if( configData.keyExists( 'componentPaths' ) ) {
configData[ 'classPaths' ] = componentPathsToClassPaths( configData.componentPaths );
configData.delete( 'componentPaths' );
}

// Convert logDirectory to logging.logsDirectory
if( configData.keyExists( 'logDirectory' ) ) {
configData[ 'logging' ] [ 'logsDirectory' ] = configData[ 'logDirectory' ];
configData.delete( 'logDirectory' );
}
// Convert logMaxFileSize to maxFileSize
// Convert logMaxFileSize to logging.maxFileSize
if( configData.keyExists( 'logMaxFileSize' ) ) {
configData[ 'logging' ] [ 'maxFileSize' ] = convertFileSizeKBToMB( configData.logMaxFileSize );
configData.delete( 'logMaxFileSize' );
Expand Down Expand Up @@ -273,6 +285,11 @@ component accessors=true extends='cfconfig-services.models.BaseConfig' {
}
}

/**
* I translate the whitespace management setting from the BoxLang format to the CFConfig format
*
* @whitespaceManagement The whitespace management setting from the BoxLang format
*/
private function translateWhitespaceFromBoxLang( required string whitespaceManagement ) {
switch( whitespaceManagement ) {
case false :
Expand Down Expand Up @@ -327,4 +344,24 @@ component accessors=true extends='cfconfig-services.models.BaseConfig' {
return round(fileSizeKB / 1024) & "MB";
}

// Convert from componentPaths (struct) to classPaths (array)
function componentPathsToClassPaths(componentPaths) {
var classPaths = [];
for (var key in componentPaths) {
arrayAppend(classPaths, componentPaths[key]);
}
return classPaths;
}

// Convert from classPaths (array) to componentPaths (struct)
function classPathsToComponentPaths(classPaths) {
var componentPaths = {};
for (var i = 1; i <= arrayLen(classPaths); i++) {
var path = classPaths[i];
var name = listLast(path, '/'); // Use the last part of the path as the name
componentPaths[name] = path;
}
return componentPaths;
}

}