-
Notifications
You must be signed in to change notification settings - Fork 0
test(cdc): rebuild replica diagnostic confidentiality on live develop #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ce73dbb
e93cdc1
e05e1d0
5cc1a68
5b47133
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,10 @@ | |
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| class ValidationUtilsTest { | ||
|
|
||
|
|
@@ -54,4 +57,50 @@ void requireValidIdentifierThrowsWhenMissingOrInvalid() { | |
| assertThrows(IllegalStateException.class, () -> ValidationUtils.requireValidIdentifier("xtrmetl?evil", "REPLICA_PGDATABASE")); | ||
| assertThrows(IllegalStateException.class, () -> ValidationUtils.requireValidIdentifier("xtrmetl/db", "REPLICA_PGDATABASE")); | ||
| } | ||
|
|
||
| @Test | ||
| void invalidConfigurationDiagnosticsDoNotRepublishRejectedValues() { | ||
| String sensitiveFragment = "password=secret-8472"; | ||
|
|
||
| IllegalStateException hostFailure = assertThrows( | ||
| IllegalStateException.class, | ||
| () -> ValidationUtils.requireValidHost( | ||
| "replica-host?" + sensitiveFragment + "\r\nforged-log-line", | ||
| "REPLICA_PGHOST" | ||
| ) | ||
| ); | ||
| IllegalStateException portFailure = assertThrows( | ||
| IllegalStateException.class, | ||
| () -> ValidationUtils.requireValidPort("5432?" + sensitiveFragment, "REPLICA_PGPORT") | ||
| ); | ||
| IllegalStateException oversizedPortFailure = assertThrows( | ||
| IllegalStateException.class, | ||
| () -> ValidationUtils.requireValidPort("999999999999999999999999999999999999", "REPLICA_PGPORT") | ||
| ); | ||
| IllegalStateException identifierFailure = assertThrows( | ||
| IllegalStateException.class, | ||
| () -> ValidationUtils.requireValidIdentifier( | ||
| "customer_db?" + sensitiveFragment, | ||
| "REPLICA_PGDATABASE" | ||
| ) | ||
| ); | ||
|
|
||
| assertSafeDiagnostic(hostFailure, "REPLICA_PGHOST", sensitiveFragment); | ||
| assertSafeDiagnostic(portFailure, "REPLICA_PGPORT", sensitiveFragment); | ||
| assertSafeDiagnostic(oversizedPortFailure, "REPLICA_PGPORT", sensitiveFragment); | ||
| assertNull(oversizedPortFailure.getCause()); | ||
| assertSafeDiagnostic(identifierFailure, "REPLICA_PGDATABASE", sensitiveFragment); | ||
| } | ||
|
|
||
| private static void assertSafeDiagnostic( | ||
| IllegalStateException failure, | ||
| String expectedKey, | ||
| String sensitiveFragment | ||
| ) { | ||
| assertTrue(failure.getMessage().contains(expectedKey)); | ||
| assertFalse(failure.getMessage().contains(sensitiveFragment)); | ||
| assertFalse(failure.getMessage().contains("forged-log-line")); | ||
| assertFalse(failure.getMessage().contains("\r")); | ||
| assertFalse(failure.getMessage().contains("\n")); | ||
| } | ||
|
Comment on lines
+60
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
while IFS= read -r -d '' file; do
printf '\n== %s ==\n' "$file"
cat "$file"
done < <(fd --hidden --type f --glob 'AGENTS.md' --print0 .)
./mvnw -B testRepository: ContextualWisdomLab/mightyETL Length of output: 219 🏁 Script executed: #!/usr/bin/env bash
set -u
printf '%s\n' '== AGENTS.md files =='
find .. -name AGENTS.md -type f -print 2>/dev/null | while IFS= read -r file; do
printf '\n== %s ==\n' "$file"
cat "$file"
done
printf '\n%s\n' '== Relevant test and implementation files =='
find . -type f \( -name 'ValidationUtilsTest.java' -o -name 'ValidationUtils.java' \) -print
printf '\n%s\n' '== Test file excerpt =='
test_file="$(find . -type f -name 'ValidationUtilsTest.java' -print -quit)"
if [ -n "$test_file" ]; then
cat -n "$test_file" | sed -n '1,150p'
fi
printf '\n%s\n' '== Implementation excerpt =='
impl_file="$(find . -type f -name 'ValidationUtils.java' -print -quit)"
if [ -n "$impl_file" ]; then
cat -n "$impl_file" | sed -n '1,220p'
fi
printf '\n%s\n' '== Maven wrapper =='
if [ -x ./mvnw ]; then
./mvnw -B test
else
printf '%s\n' './mvnw is missing or is not executable'
exit 2
fiRepository: ContextualWisdomLab/mightyETL Length of output: 50386 🏁 Script executed: #!/usr/bin/env bash
set -u
log=/tmp/coderabbit-shell-logs/shell-output-Ttu25l
printf '%s\n' '== Maven failure summary =='
if [ -f "$log" ]; then
grep -E '(^\[ERROR\]|BUILD |Tests run:|Failures:|Errors:|There are test failures|Failed to execute)' "$log" | tail -n 120
printf '\n%s\n' '== Maven output tail =='
tail -n 120 "$log"
else
printf '%s\n' "Missing log: $log"
fi
printf '\n%s\n' '== Targeted ValidationUtilsTest =='
set -o pipefail
./mvnw -B -pl cdc-service -Dtest=ValidationUtilsTest test 2>&1 \
| tee /tmp/validation-utils-test.log \
| grep -E '(^\[INFO\] ---|Tests run:|(^\[ERROR\])|BUILD (SUCCESS|FAILURE)|Failed to execute|No tests were executed)' \
| tail -n 160
status=${PIPESTATUS[0]}
printf '\nMaven exit status: %s\n' "$status"
exit "$status"Repository: ContextualWisdomLab/mightyETL Length of output: 15644 🏁 Script executed: #!/usr/bin/env bash
set -u
printf '%s\n' '== Related diagnostic helpers and timeout tests =='
rg -n -C 4 'assertSafeDiagnostic|timeout|DoNotRepublish|republish|sensitiveFragment' \
cdc-service/src/test/java cdc-service/src/main/java 2>/dev/null || true
printf '\n%s\n' '== Java runtime =='
java -version 2>&1 || true
javac -version 2>&1 || true
printf '\n%s\n' '== Targeted cdc-service test =='
log=/tmp/validation-utils-test-direct.log
./mvnw -B -pl cdc-service -Dtest=ValidationUtilsTest test >"$log" 2>&1
status=$?
grep -E '(^\[INFO\] ---|Tests run:|(^\[ERROR\])|BUILD (SUCCESS|FAILURE)|Failed to execute|No tests were executed|SKIPPED)' "$log" | tail -n 160
printf '\nMaven exit status: %s\n' "$status"
exit "$status"Repository: ContextualWisdomLab/mightyETL Length of output: 13117 🏁 Script executed: #!/usr/bin/env bash
python3 - <<'PY'
def helper_passes(message, expected_key, sensitive_fragment):
return (
expected_key in message
and sensitive_fragment not in message
and "forged-log-line" not in message
and "\r" not in message
and "\n" not in message
)
cases = [
(
"host",
"Invalid host for REPLICA_PGHOST: replica-host?",
"REPLICA_PGHOST",
"password=secret-8472",
),
(
"port",
"Invalid port for REPLICA_PGPORT: 5432?",
"REPLICA_PGPORT",
"password=secret-8472",
),
(
"identifier",
"Invalid value for REPLICA_PGDATABASE: customer_db?",
"REPLICA_PGDATABASE",
"password=secret-8472",
),
]
for name, message, key, fragment in cases:
print(f"{name}: {'passes' if helper_passes(message, key, fragment) else 'fails'}")
PYRepository: ContextualWisdomLab/mightyETL Length of output: 212 거부된 입력의 비노출 범위를 확대해 검사하세요.
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
두 진단 테스트가 거부된 입력의 부분 재출력을 허용합니다.
두 헬퍼는 선택한 민감한 조각만 검사합니다. 거부된 입력의 다른 부분이 진단에 남아도 회귀가 통과할 수 있습니다. 전체 입력과 안전한 오류 메시지를 함께 검증해 주세요.
cdc-service/src/test/java/com/xtrmetl/cdc/util/ValidationUtilsTest.java#L88-L104: 각 검증 실패에 전체 거부 값을 전달하고, 전체 값과 안정적인 오류 메시지를 검사하세요.cdc-service/src/test/java/com/xtrmetl/cdc/config/ReplicaJdbcTemplateConfigTest.java#L102-L105: 전체 타임아웃 값과not-a-number?부분을 검사하고, 안전한IllegalStateException메시지를 확인하세요.📍 Affects 2 files
cdc-service/src/test/java/com/xtrmetl/cdc/util/ValidationUtilsTest.java#L88-L104(this comment)cdc-service/src/test/java/com/xtrmetl/cdc/config/ReplicaJdbcTemplateConfigTest.java#L102-L105🤖 Prompt for AI Agents