Skip to content

Commit

Permalink
Updating terminology used in the host
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocav committed Aug 12, 2020
1 parent 95dc10e commit 8281ff0
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal IEnumerable<FunctionMetadata> GetFunctionsMetadata(bool includeProxies,
filterPredicate = m => m.IsProxy() || !m.IsCodeless();
}

return _functionMetadataManager.GetFunctionMetadata(forceRefresh, applyWhitelist: false).Where(filterPredicate);
return _functionMetadataManager.GetFunctionMetadata(forceRefresh, applyAllowlist: false).Where(filterPredicate);
}

/// <summary>
Expand Down
24 changes: 12 additions & 12 deletions src/WebJobs.Script/Host/FunctionMetadataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,30 @@ public bool TryGetFunctionMetadata(string functionName, out FunctionMetadata fun
/// Gets the function metadata array from all providers.
/// </summary>
/// <param name="forceRefresh">Forces reload from all providers.</param>
/// <param name="applyWhitelist">Apply functions whitelist filter.</param>
/// <param name="applyAllowList">Apply functions allow list filter.</param>
/// <returns> An Immmutable array of FunctionMetadata.</returns>
public ImmutableArray<FunctionMetadata> GetFunctionMetadata(bool forceRefresh, bool applyWhitelist = true)
public ImmutableArray<FunctionMetadata> GetFunctionMetadata(bool forceRefresh, bool applyAllowList = true)
{
if (forceRefresh || _servicesReset || _functionMetadataArray.IsDefaultOrEmpty)
{
_functionMetadataArray = LoadFunctionMetadata(forceRefresh);
_logger.FunctionMetadataManagerFunctionsLoaded(ApplyWhitelist(_functionMetadataArray).Count());
_logger.FunctionMetadataManagerFunctionsLoaded(ApplyAllowList(_functionMetadataArray).Count());
_servicesReset = false;
}

return applyWhitelist ? ApplyWhitelist(_functionMetadataArray) : _functionMetadataArray;
return applyAllowList ? ApplyAllowList(_functionMetadataArray) : _functionMetadataArray;
}

private ImmutableArray<FunctionMetadata> ApplyWhitelist(ImmutableArray<FunctionMetadata> metadataList)
private ImmutableArray<FunctionMetadata> ApplyAllowList(ImmutableArray<FunctionMetadata> metadataList)
{
var whitelist = _scriptOptions.Value?.Functions;
var allowList = _scriptOptions.Value?.Functions;

if (whitelist == null || metadataList.IsDefaultOrEmpty)
if (allowList == null || metadataList.IsDefaultOrEmpty)
{
return metadataList;
}

return metadataList.Where(metadata => whitelist.Any(functionName => functionName.Equals(metadata.Name, StringComparison.CurrentCultureIgnoreCase))).ToImmutableArray();
return metadataList.Where(metadata => allowList.Any(functionName => functionName.Equals(metadata.Name, StringComparison.CurrentCultureIgnoreCase))).ToImmutableArray();
}

private void InitializeServices()
Expand All @@ -123,7 +123,7 @@ internal ImmutableArray<FunctionMetadata> LoadFunctionMetadata(bool forceRefresh
{
_functionMetadataMap.Clear();

ICollection<string> functionsWhiteList = _scriptOptions?.Value?.Functions;
ICollection<string> functionsAllowList = _scriptOptions?.Value?.Functions;
_logger.FunctionMetadataManagerLoadingFunctionsMetadata();

var immutableFunctionMetadata = _functionMetadataProvider.GetFunctionMetadata(_languageWorkerOptions.Value.WorkerConfigs, forceRefresh);
Expand Down Expand Up @@ -154,10 +154,10 @@ internal ImmutableArray<FunctionMetadata> LoadFunctionMetadata(bool forceRefresh
}
Errors = _functionErrors.ToImmutableDictionary(kvp => kvp.Key, kvp => kvp.Value.ToImmutableArray());

if (functionsWhiteList != null)
if (functionsAllowList != null)
{
_logger.LogInformation($"A function whitelist has been specified, excluding all but the following functions: [{string.Join(", ", functionsWhiteList)}]");
Errors = _functionErrors.Where(kvp => functionsWhiteList.Any(functionName => functionName.Equals(kvp.Key, StringComparison.CurrentCultureIgnoreCase))).ToImmutableDictionary(kvp => kvp.Key, kvp => kvp.Value.ToImmutableArray());
_logger.LogInformation($"A function allow list has been specified, excluding all but the following functions: [{string.Join(", ", functionsAllowList)}]");
Errors = _functionErrors.Where(kvp => functionsAllowList.Any(functionName => functionName.Equals(kvp.Key, StringComparison.CurrentCultureIgnoreCase))).ToImmutableDictionary(kvp => kvp.Key, kvp => kvp.Value.ToImmutableArray());
}

return functionMetadataList.ToImmutableArray();
Expand Down
2 changes: 1 addition & 1 deletion src/WebJobs.Script/Host/IFunctionMetadataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IFunctionMetadataManager
{
ImmutableDictionary<string, ImmutableArray<string>> Errors { get; }

ImmutableArray<FunctionMetadata> GetFunctionMetadata(bool forceRefresh = false, bool applyWhitelist = true);
ImmutableArray<FunctionMetadata> GetFunctionMetadata(bool forceRefresh = false, bool applyAllowlist = true);

bool TryGetFunctionMetadata(string functionName, out FunctionMetadata functionMetadata, bool forceRefresh = false);
}
Expand Down
14 changes: 7 additions & 7 deletions src/WebJobs.Script/Workers/Rpc/RpcInitializationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RpcInitializationService : IManagedHostedService
private readonly string _workerRuntime;
private readonly int _rpcServerShutdownTimeoutInMilliseconds;

private Dictionary<OSPlatform, List<string>> _hostingOSToWhitelistedRuntimes = new Dictionary<OSPlatform, List<string>>()
private Dictionary<OSPlatform, List<string>> _hostingOSToRuntimesAllowList = new Dictionary<OSPlatform, List<string>>()
{
{
OSPlatform.Windows,
Expand All @@ -41,12 +41,12 @@ public class RpcInitializationService : IManagedHostedService
};

// _webHostLevelWhitelistedRuntimes are started at webhost level when running in Azure and locally
private List<string> _webHostLevelWhitelistedRuntimes = new List<string>()
private List<string> _webHostLeveldRuntimesAllowList = new List<string>()
{
RpcWorkerConstants.JavaLanguageWorkerName
};

private List<string> _placeholderPoolWhitelistedRuntimes = new List<string>()
private List<string> _placeholderPoolRuntimesAllowList = new List<string>()
{
RpcWorkerConstants.JavaLanguageWorkerName,
RpcWorkerConstants.NodeLanguageWorkerName,
Expand Down Expand Up @@ -158,13 +158,13 @@ private Task InitializePlaceholderChannelsAsync()

private Task InitializePlaceholderChannelsAsync(OSPlatform os)
{
return Task.WhenAll(_hostingOSToWhitelistedRuntimes[os].Select(runtime =>
return Task.WhenAll(_hostingOSToRuntimesAllowList[os].Select(runtime =>
_webHostRpcWorkerChannelManager.InitializeChannelAsync(runtime)));
}

private Task InitializeWebHostRuntimeChannelsAsync()
{
if (_webHostLevelWhitelistedRuntimes.Contains(_workerRuntime, StringComparer.OrdinalIgnoreCase))
if (_webHostLeveldRuntimesAllowList.Contains(_workerRuntime, StringComparer.OrdinalIgnoreCase))
{
return _webHostRpcWorkerChannelManager.InitializeChannelAsync(_workerRuntime);
}
Expand All @@ -191,10 +191,10 @@ internal bool ShouldStartAsPlaceholderPool()
// We are in placeholder mode but a worker runtime IS set
return _environment.IsPlaceholderModeEnabled()
&& !string.IsNullOrEmpty(_workerRuntime)
&& _placeholderPoolWhitelistedRuntimes.Contains(_workerRuntime, StringComparer.OrdinalIgnoreCase);
&& _placeholderPoolRuntimesAllowList.Contains(_workerRuntime, StringComparer.OrdinalIgnoreCase);
}

// To help with unit tests
internal void AddSupportedWebHostLevelRuntime(string language) => _webHostLevelWhitelistedRuntimes.Add(language);
internal void AddSupportedWebHostLevelRuntime(string language) => _webHostLeveldRuntimesAllowList.Add(language);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ await TestHelpers.Await(() =>

int idx = 0;
ValidateTrace(traces[idx++], "2 functions loaded", LogCategories.Startup);
ValidateTrace(traces[idx++], "A function whitelist has been specified", LogCategories.Startup);
ValidateTrace(traces[idx++], "A function allow list has been specified", LogCategories.Startup);
ValidateTrace(traces[idx++], "Found the following functions:\r\n", LogCategories.Startup);
ValidateTrace(traces[idx++], "Generating 2 job function(s)", LogCategories.Startup);
ValidateTrace(traces[idx++], "Host initialization: ConsecutiveErrors=0, StartupCount=1", LogCategories.Startup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public async Task CodelessFunction_CanUse_MultipleProviders(string path, string
[InlineData("NoFunction", "node", null, 0)]
public async Task CodelessFunction_DoesNot_ListFunctions(string path, string workerRuntime, string allowedList, int listCount)
{
// Note: admin/functions call includes all functions, regardless of the allowed list (whitelist)
// Note: admin/functions call includes all functions, regardless of the allowed list
var sourceFunctionApp = Path.Combine(Environment.CurrentDirectory, "TestScripts", path);
var settings = new Dictionary<string, string>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public MockMetadataManager(ICollection<FunctionMetadata> functions)
public ImmutableDictionary<string, ImmutableArray<string>> Errors =>
ImmutableDictionary<string, ImmutableArray<string>>.Empty;

public ImmutableArray<FunctionMetadata> GetFunctionMetadata(bool forceRefresh = false, bool applyWhitelist = true)
public ImmutableArray<FunctionMetadata> GetFunctionMetadata(bool forceRefresh = false, bool applyAllowlist = true)
{
return _functions.ToImmutableArray();
}
Expand Down

0 comments on commit 8281ff0

Please sign in to comment.