Skip to content
Closed
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
6 changes: 3 additions & 3 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 2024-07-04 - R 언어에서 루프 내 데이터 프레임 탐색 병목 최적화
**Learning:** R에서 루프를 돌면서 매번 데이터 프레임을 서브셋팅(subsetting)하는 작업은 복사 오버헤드로 인해 매우 느려질있습니다. 특히 공통 문항 수가 많아질 경우 O(N^2)의 비효율을 초래합니다.
**Action:** 루프 내에서 수행하던 데이터 프레임 조회를 루프 외부에서 한 번에 `as.character(unlist(...))`로 처리하는 벡터 연산으로 변경하여 타입 변환 없이 O(1) 수준으로 성능을 크게 향상시킬 수 있습니다.
## 2024-05-24 - Base R String Subsetting Optimization
**Learning:** 여러 개의 부정 `grep()` 출력을 결합하여 벡터를 필터링하는 방식(예: `x[-c(grep("A", x), grep("B", x))]`)은 성능 저하(패턴K에 대해 O(K*N))를 유발할 뿐만 아니라 안전하지 않습니다. 패턴과 일치하는 항목이 없을 경우, 이는 `x[-integer(0)]`으로 평가되어 잘못하여 전체 벡터를 삭제(`character(0)` 반환)하게 됩니다.
**Action:** 문자열 벡터에서 여러 패턴을 제외하여 필터링할 때는 항상 정규표현식의 OR 기호를 사용한 `!grepl("^(A|B)", x)` 구조를 채택하여 성능 향상과 안전성을 모두 확보하십시오.
22 changes: 22 additions & 0 deletions .trivyignore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Trivy ignore rules (.trivyignore.yaml)
#
# Loaded via trivy.yaml (`ignorefile: .trivyignore.yaml`) so it applies to a
# bare `trivy fs .`. Trivy 0.71.x only auto-detects a plain `.trivyignore`
# (line-based, NO path scoping); the YAML form used here is what lets us scope
# the suppression to a single path instead of disabling a rule globally.
#
# Scope: ONE path-scoped secret suppression. This does NOT globally disable
# private-key detection — a real private key committed anywhere else in the
# repo will still fail the scan.
#
# Why this single entry is safe (verified false positive):
# The R "openssl" package is vendored under packrat/ for reproducible builds.
# Its bundled upstream HTML docs (openssl/doc/keys.html) print an EXAMPLE PEM
# key from the doc's own `write_pem()` demonstration. It is published upstream
# example material, not a live credential, so Trivy's Secret rule "private-key"
# (AsymmetricPrivateKey, HIGH) is a false positive here. We scope the ignore to
# exactly this vendored doc path.
secrets:
- id: private-key
paths:
- "packrat/lib/**/openssl/doc/keys.html"
9 changes: 3 additions & 6 deletions R/aFIPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,11 @@ autoFIPC <-
# IPD estimation
IPDParmNames <- OldScaleParms$name
IPDParmNames <- IPDParmNames[!duplicated(IPDParmNames)]
# ⚡ Bolt: 여러 개의 부정 grep() 호출을 단일 !grepl() 호출로 교체하여 O(N) 최적화
# base R의 integer(0) subsetting 버그(벡터 전체 삭제)를 방지하여 안정성 확보
IPDParmNames <-
IPDParmNames[
-c(
grep("^MEAN", IPDParmNames),
grep("^COV", IPDParmNames),
grep("^ak", IPDParmNames),
grep("^d0$", IPDParmNames)
)
!grepl("^(MEAN|COV|ak|d0$)", IPDParmNames)
]
IPDParmNames <- as.character(IPDParmNames)

Expand Down
8 changes: 8 additions & 0 deletions trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Trivy configuration (auto-loaded from the repo root by `trivy fs .`).
#
# Its only job is to activate the path-scoped secret suppression in
# .trivyignore.yaml. Trivy 0.71.x auto-detects only a plain `.trivyignore`
# (which cannot scope a rule to a path); pointing `ignorefile` at the YAML file
# lets us suppress the vendored-doc false positive WITHOUT globally disabling
# private-key detection. See .trivyignore.yaml for the full justification.
ignorefile: .trivyignore.yaml
Loading