Skip to content

Commit 4c7d43c

Browse files
authored
fix: enable iframe script execution (apache#52257)
* fix: enable iframe script execution * fix: include vite env variables when transpiling typescripts * fix: add explanations to sandbox settings * fix: remove csp change
1 parent 60f780e commit 4c7d43c

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

airflow-core/src/airflow/ui/src/pages/Iframe.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ export const Iframe = () => {
4444
return <ErrorPage />;
4545
}
4646

47+
// The following iframe sandbox setting is intentionally less restrictive.
48+
// ONLY trusted contents can be framed within Iframe.
49+
const sandbox = "allow-same-origin allow-forms";
50+
4751
return (
4852
<Box flexGrow={1} m={-3}>
4953
<iframe
50-
sandbox="allow-same-origin allow-forms"
54+
sandbox={sandbox}
5155
src={iframeView.href}
5256
style={{ height: "100%", width: "100%" }}
5357
title={iframeView.name}

airflow-core/src/airflow/ui/src/pages/Security.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ export const Security = () => {
4343
return <ErrorPage />;
4444
}
4545

46+
// The following iframe sandbox setting is intentionally less restrictive.
47+
// This is considered safe because the framed content originates from the Auth manager,
48+
// which is part of the deployment of Airflow and trusted as per our security policy.
49+
// https://airflow.apache.org/docs/apache-airflow/stable/security/security_model.html
50+
const sandbox = "allow-scripts allow-same-origin allow-forms";
51+
4652
return (
4753
<Box flexGrow={1} m={-3}>
48-
<iframe
49-
sandbox="allow-same-origin allow-forms"
50-
src={link.href}
51-
style={{ height: "100%", width: "100%" }}
52-
title={link.text}
53-
/>
54+
<iframe sandbox={sandbox} src={link.href} style={{ height: "100%", width: "100%" }} title={link.text} />
5455
</Box>
5556
);
5657
};

scripts/ci/pre_commit/ts_compile_lint_ui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
all_non_yaml_files = [file for file in files if not file.endswith(".yaml")]
4848
print("All non-YAML files:", all_non_yaml_files)
4949
all_ts_files = [file for file in files if file.endswith(".ts") or file.endswith(".tsx")]
50+
if all_ts_files:
51+
all_ts_files.append("src/vite-env.d.ts")
5052
print("All TypeScript files:", all_ts_files)
5153

5254
run_command(["pnpm", "config", "set", "store-dir", ".pnpm-store"], cwd=dir)

0 commit comments

Comments
 (0)