This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/main by this push:
new 0c3dc31 Shorten known absolute paths in RAT commands
0c3dc31 is described below
commit 0c3dc3105a6d819eb11faf7908b6dc370a4f1018
Author: Sean B. Palmer <[email protected]>
AuthorDate: Tue Jan 13 16:11:56 2026 +0000
Shorten known absolute paths in RAT commands
---
atr/tasks/checks/rat.py | 14 +++++++++++++-
tests/unit/test_checks_rat.py | 18 ++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/atr/tasks/checks/rat.py b/atr/tasks/checks/rat.py
index 94d13e1..5b383ba 100644
--- a/atr/tasks/checks/rat.py
+++ b/atr/tasks/checks/rat.py
@@ -313,6 +313,18 @@ def _is_inside_directory(path: str, directory: str) ->
bool:
return path.startswith(directory + os.sep)
+def _sanitise_command_for_storage(command: list[str]) -> list[str]:
+ """Replace absolute paths with filenames for known arguments."""
+ path_args = {"-jar", "--output-file"}
+ result: list[str] = []
+ for i, arg in enumerate(command):
+ if (i > 0) and (command[i - 1] in path_args) and os.path.isabs(arg):
+ result.append(os.path.basename(arg))
+ else:
+ result.append(arg)
+ return result
+
+
def _summary_message(valid: bool, unapproved_licenses: int, unknown_licenses:
int) -> str:
message = "All files have approved licenses"
if not valid:
@@ -524,7 +536,7 @@ def _synchronous_extract(
result.excludes_source = excludes_source
result.extended_std_applied = apply_extended_std
- result.command = command
+ result.command = _sanitise_command_for_storage(command)
return result
diff --git a/tests/unit/test_checks_rat.py b/tests/unit/test_checks_rat.py
index 74f94c0..02ed99c 100644
--- a/tests/unit/test_checks_rat.py
+++ b/tests/unit/test_checks_rat.py
@@ -55,6 +55,24 @@ def
test_check_includes_excludes_source_policy(rat_available: tuple[bool, bool])
assert result.excludes_source == "policy"
+def test_sanitise_command_replaces_absolute_paths():
+ command = [
+ "java",
+ "-jar",
+ "/opt/tools/apache-rat-0.17.jar",
+ "--output-file",
+ "/fake/path/rat_verify_abc123/rat-report.xml",
+ "--input-exclude",
+ ".rat-excludes",
+ "--",
+ ".",
+ ]
+ result = rat._sanitise_command_for_storage(command)
+ assert result[2] == "apache-rat-0.17.jar"
+ assert result[4] == "rat-report.xml"
+ assert result[6] == ".rat-excludes"
+
+
def _skip_if_unavailable(rat_available: tuple[bool, bool]) -> None:
java_ok, jar_ok = rat_available
if not java_ok:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]