Skip to content

test(cdc): rebuild replica diagnostic confidentiality on live develop - #283

Closed
seonghobae wants to merge 5 commits into
developfrom
fix/cdc-validation-diagnostic-confidentiality-106add
Closed

test(cdc): rebuild replica diagnostic confidentiality on live develop#283
seonghobae wants to merge 5 commits into
developfrom
fix/cdc-validation-diagnostic-confidentiality-106add

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Supersedes stale/diverged PR #211 for issue #210 without transferring old-head checks or reviews.

Exact live base at creation: develop@106add38465937f6eb4e4accc185fd30aab4446f.

Superseded by #301

Closed as superseded after unique-work preservation was revalidated against #301 current head 9eef90b09bb14a72ac63478dacaacae8222f2b51.

No checks, reviews, or approval evidence from this PR transfer to #301. #301 remains responsible for fresh exact-head CI/security/non-vacuous coverage and qualifying independent approval before merge.

Summary by CodeRabbit

  • 버그 수정

    • 설정 및 입력값 검증 오류 메시지에서 민감한 입력값과 내부 예외 정보가 노출되지 않도록 개선했습니다.
    • 오류 메시지에 개행 문자가 포함되지 않아 로그 오염 가능성을 줄였습니다.
    • 검증 성공 시 기존과 같이 공백이 제거된 값이 반환됩니다.
  • 테스트

    • 민감한 값과 비정상 입력에 대한 오류 진단 동작을 보강했습니다.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

검증 및 복제본 초기화 오류 메시지에서 입력값과 원인 예외를 제거했습니다. 포트·호스트·식별자 검증과 초기화 타임아웃 파싱에 대한 민감정보 비노출 테스트를 추가했습니다.

Changes

진단 정보 비노출 처리

Layer / File(s) Summary
검증 오류 진단 정리
cdc-service/src/main/java/com/xtrmetl/cdc/util/ValidationUtils.java, cdc-service/src/test/java/com/xtrmetl/cdc/util/ValidationUtilsTest.java
포트, 호스트, 식별자 오류 메시지에서 입력값을 제거했습니다. 포트 변환 예외의 원인도 연결하지 않습니다. 성공 시 트림된 값을 반환하는 동작을 문서화하고 검증합니다.
복제본 초기화 오류 진단 정리
cdc-service/src/main/java/com/xtrmetl/cdc/config/ReplicaJdbcTemplateConfig.java, cdc-service/src/test/java/com/xtrmetl/cdc/config/ReplicaJdbcTemplateConfigTest.java
초기화 타임아웃 오류에서 설정값과 NumberFormatException을 제거했습니다. 설정 키는 유지되는지 확인합니다.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related issues

  • 이슈 210 — 검증 및 초기화 오류 진단에서 입력값과 파서 원인 예외를 제거하는 목표가 이 변경과 일치합니다.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 replica 진단 정보의 기밀성 개선이라는 변경의 핵심을 명확히 설명합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cdc-validation-diagnostic-confidentiality-106add

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as ready for review August 11, 2026 21:19
@seonghobae
seonghobae marked this pull request as draft August 11, 2026 21:42
@seonghobae
seonghobae marked this pull request as ready for review August 11, 2026 22:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cdc-service/src/test/java/com/xtrmetl/cdc/util/ValidationUtilsTest.java`:
- Around line 88-104: Update ValidationUtilsTest.java at lines 88-104 so each
validation failure passes the complete rejected value to assertSafeDiagnostic,
and have the helper verify that the complete value is absent along with the
stable error-message safety checks. Update ReplicaJdbcTemplateConfigTest.java at
lines 102-105 to validate the complete timeout value and the “not-a-number?”
fragment, while confirming the resulting IllegalStateException message is safe.
- Around line 60-105: Expand assertSafeDiagnostic in ValidationUtilsTest so each
failure message and entire exception-cause chain are checked for absence of the
complete rejected input, not only sensitiveFragment and forged-log-line. Pass
the full host, port, and identifier inputs to the helper, and add a separate
full-input assertion for oversizedPortFailure while preserving key and newline
checks. Apply the same diagnostic-safety assertions to
ReplicaJdbcTemplateConfigTest.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 90bd866e-5b4f-4906-bc65-b81d862fecb3

📥 Commits

Reviewing files that changed from the base of the PR and between ae4efe6 and 5b47133.

📒 Files selected for processing (4)
  • cdc-service/src/main/java/com/xtrmetl/cdc/config/ReplicaJdbcTemplateConfig.java
  • cdc-service/src/main/java/com/xtrmetl/cdc/util/ValidationUtils.java
  • cdc-service/src/test/java/com/xtrmetl/cdc/config/ReplicaJdbcTemplateConfigTest.java
  • cdc-service/src/test/java/com/xtrmetl/cdc/util/ValidationUtilsTest.java

Comment on lines +60 to +105

@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"));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 test

Repository: 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
fi

Repository: 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'}")
PY

Repository: ContextualWisdomLab/mightyETL

Length of output: 212


거부된 입력의 비노출 범위를 확대해 검사하세요.

assertSafeDiagnostic는 민감한 조각과 "forged-log-line"만 검사합니다. 따라서 "Invalid host for REPLICA_PGHOST: replica-host?"와 같은 부분 누출은 통과합니다. 각 거부 입력 전체와 예외 원인 체인에 입력 값이 없는지 검사하세요. oversizedPortFailure에는 sensitiveFragment가 전달되지 않으므로 별도의 입력값 검사가 필요합니다. 동일한 검사를 ReplicaJdbcTemplateConfigTest에도 적용하세요.

./mvnw -B test와 대상 테스트는 JDK 17이 Java release 25를 지원하지 않아 실행되지 않았습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cdc-service/src/test/java/com/xtrmetl/cdc/util/ValidationUtilsTest.java`
around lines 60 - 105, Expand assertSafeDiagnostic in ValidationUtilsTest so
each failure message and entire exception-cause chain are checked for absence of
the complete rejected input, not only sensitiveFragment and forged-log-line.
Pass the full host, port, and identifier inputs to the helper, and add a
separate full-input assertion for oversizedPortFailure while preserving key and
newline checks. Apply the same diagnostic-safety assertions to
ReplicaJdbcTemplateConfigTest.

Source: Coding guidelines

Comment on lines +88 to +104
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"));

Copy link
Copy Markdown
Contributor

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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cdc-service/src/test/java/com/xtrmetl/cdc/util/ValidationUtilsTest.java`
around lines 88 - 104, Update ValidationUtilsTest.java at lines 88-104 so each
validation failure passes the complete rejected value to assertSafeDiagnostic,
and have the helper verify that the complete value is absent along with the
stable error-message safety checks. Update ReplicaJdbcTemplateConfigTest.java at
lines 102-105 to validate the complete timeout value and the “not-a-number?”
fragment, while confirming the resulting IllegalStateException message is safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant