Skip to content

Commit

Permalink
Revert "try an allowlist"
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharkes committed Nov 28, 2024
1 parent fc010ec commit 00f4f2d
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ class NativeAssetsBuildRunner {
null,
hookKernelFile,
packageLayout!,
_filteredEnvironment(_environmentVariablesFilter),
),
);
if (buildOutput == null) return null;
Expand Down Expand Up @@ -490,7 +489,6 @@ class NativeAssetsBuildRunner {
final environmentFile = File.fromUri(
config.outputDirectory.resolve('../environment.json'),
);
final environment = _filteredEnvironment(_environmentVariablesFilter);
if (buildOutputFile.existsSync() &&
dependenciesHashFile.existsSync() &&
environmentFile.existsSync()) {
Expand All @@ -514,7 +512,7 @@ ${e.message}
!const MapEquality<String, String>().equals(
(json.decode(await environmentFile.readAsString()) as Map)
.cast<String, String>(),
environment);
Platform.environment);
if (!dependenciesOutdated && !environmentChanged) {
logger.info(
[
Expand All @@ -537,15 +535,14 @@ ${e.message}
resources,
hookKernelFile,
packageLayout,
environment,
);
if (result == null) {
if (await dependenciesHashFile.exists()) {
await dependenciesHashFile.delete();
}
} else {
await environmentFile.writeAsString(
json.encode(environment),
json.encode(Platform.environment),
);
final modifiedDuringBuild = await dependenciesHashes.hashFiles(
[
Expand All @@ -564,18 +561,6 @@ ${e.message}
);
}

/// Limit the environment that hook invocations get to see.
///
/// This allowlist lists environment variables needed to run mainstream
/// compilers.
static const _environmentVariablesFilter = {
'ANDROID_HOME',
'PATH',
'SYSTEMROOT',
'TEMP',
'TMP',
};

Future<HookOutput?> _runHookForPackage(
Hook hook,
HookConfig config,
Expand All @@ -585,7 +570,6 @@ ${e.message}
Uri? resources,
File hookKernelFile,
PackageLayout packageLayout,
Map<String, String> environment,
) async {
final configFile = config.outputDirectory.resolve('../config.json');
final configFileContents =
Expand All @@ -610,8 +594,6 @@ ${e.message}
executable: dartExecutable,
arguments: arguments,
logger: logger,
includeParentEnvironment: false,
environment: environment,
);

var deleteOutputIfExists = false;
Expand Down Expand Up @@ -668,12 +650,6 @@ ${e.message}
}
}

Map<String, String> _filteredEnvironment(Set<String> allowList) => {
for (final entry in Platform.environment.entries)
if (allowList.contains(entry.key.toUpperCase()))
entry.key: entry.value,
};

/// Compiles the hook to kernel and caches the kernel.
///
/// If any of the Dart source files, or the package config changed after
Expand Down Expand Up @@ -776,8 +752,6 @@ ${e.message}
executable: dartExecutable,
arguments: compileArguments,
logger: logger,
includeParentEnvironment: false,
environment: _filteredEnvironment({'HOME', 'PUB_CACHE'}),
);
var success = true;
if (compileResult.exitCode != 0) {
Expand Down

0 comments on commit 00f4f2d

Please sign in to comment.