Skip to content
Merged
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
25 changes: 25 additions & 0 deletions bazel/rules/rules_angular/src/optimization/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,36 @@ def optimize_angular_app(
root_paths = [""],
)

native.genrule(
name = "_%s_check_symlinks" % name,
srcs = srcs,
outs = ["_%s_check_symlinks_passed.txt" % name],
cmd = """
for f in $(SRCS) ""; do
if [ -z "$$f" ]; then continue; fi
target=$$(readlink "$$f" || true)
if [ -n "$$target" ]; then
case "$$target" in
/*) ;;
*) target="$$(dirname "$$f")/$$target" ;;
esac
if [ -h "$$target" ]; then
echo "Security violation: Symbolic links are not permitted in user input. ($$f)" >&2
exit 1
fi
fi
done
touch $@
""",
Comment thread
josephperrott marked this conversation as resolved.
tags = ["manual"],
)

run_binary(
name = "_%s_build" % name,
tool = "@rules_angular//src/optimization:optimize",
tags = ["manual"],
srcs = [
":_%s_check_symlinks" % name,
":_%s_package" % name,
"@yq_toolchains//:resolved_toolchain",
"@rules_angular//src/optimization/boilerplate",
Expand Down
2 changes: 1 addition & 1 deletion bazel/rules/rules_angular/src/optimization/optimize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NG_CLI_TOOL="$RUNFILES/$NG_CLI_TOOL_RUNFILES_PATH"
cp -Rf -L $BOILERPLATE_DIR/* $OUT_DIR

# Copy user files.
cp -Rf -L $INPUT_PACKAGE/* $OUT_DIR/src/
cp -Rf $INPUT_PACKAGE/* $OUT_DIR/src/

# Prepare for `angular.json` to be modified below.
unlink $OUT_DIR/angular.json
Expand Down
Loading