Skip to content

Commit

Permalink
BL-423 #resolve
Browse files Browse the repository at this point in the history
New experimental features block on the `boxlang.json`
  • Loading branch information
lmajano committed Aug 9, 2024
1 parent 5aecc32 commit 1c047ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/main/java/ortus/boxlang/runtime/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,13 @@ public class Configuration implements IConfigSegment {
/**
* File extensions which are disallowed for file operations. The allowed array overrides any items in the disallow list.
*/
public List<String> allowedFileOperationExtensions = new ArrayList<String>();
public List<String> allowedFileOperationExtensions = new ArrayList<>();
public List<String> disallowedFileOperationExtensions = new ArrayList<>();

public List<String> disallowedFileOperationExtensions = new ArrayList<String>();
/**
* Experimental Features
*/
public IStruct experimental = new Struct();

/**
* --------------------------------------------------------------------------
Expand Down Expand Up @@ -426,6 +430,15 @@ public Configuration process( IStruct config ) {
}
}

// Process experimentals map
if ( config.containsKey( Key.experimental ) ) {
if ( config.get( Key.experimental ) instanceof Map<?, ?> castedMap ) {
castedMap.forEach( ( key, value ) -> this.experimental.put( Key.of( key ), PlaceholderHelper.resolve( value ) ) );
} else {
logger.warn( "The [runtime.experimental] configuration is not a JSON Object, ignoring it." );
}
}

// Process default datasource configuration
if ( config.containsKey( Key.defaultDatasource ) ) {
this.defaultDatasource = PlaceholderHelper.resolve( config.get( Key.defaultDatasource ) );
Expand Down Expand Up @@ -726,6 +739,9 @@ public IStruct asStruct() {
Key.debugMode, this.debugMode,
Key.defaultCache, this.defaultCache.toStruct(),
Key.defaultDatasource, this.defaultDatasource,
Key.disallowedFileOperationExtensions, Array.fromList( this.disallowedFileOperationExtensions ),
Key.allowedFileOperationExtensions, Array.fromList( this.allowedFileOperationExtensions ),
Key.experimental, Struct.fromMap( this.experimental ),
Key.executors, executorsCopy,
Key.invokeImplicitAccessor, this.invokeImplicitAccessor,
Key.javaLibraryPaths, Array.fromList( this.javaLibraryPaths ),
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ortus/boxlang/runtime/scopes/Key.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public class Key implements Comparable<Key>, Serializable {
public static final Key escapeChars = Key.of( "escapeChars" );
public static final Key evictCount = Key.of( "evictCount" );
public static final Key evictionPolicy = Key.of( "evictionPolicy" );
public static final Key experimental = Key.of( "experimental" );
public static final Key execute = Key.of( "execute" );
public static final Key executionMode = Key.of( "executionMode" );
public static final Key executionState = Key.of( "executionState" );
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/config/boxlang.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
],
// The location of the log files the runtime will produce
"logsDirectory": "${boxlang-home}/logs",
// This is the experimental features flags.
// Please see the documentation to see which flags are available
"experimental": {},
// Global Executors for the runtime
// These are managed by the AsyncService and registered upon startup
// The name of the executor is the key and the value is a struct of executor settings
Expand Down Expand Up @@ -85,9 +88,9 @@
// }
},
// An explicit whitelist of file extensions that are allowed to be uploaded - overrides any values in the disallowedWriteExtensions
"allowedFileOperationExtensions" : [],
"allowedFileOperationExtensions": [],
// The list of file extensions that are not allowed to be uploaded. Also enforced by file relocation operations ( e.g. copy/move )
"disallowedFileOperationExtensions" : [
"disallowedFileOperationExtensions": [
"bat",
"exe",
"cmd",
Expand Down

0 comments on commit 1c047ef

Please sign in to comment.