Philipp Ottlinger created RAT-589:
-------------------------------------

             Summary: Header line limit is dead code — whole files buffered in 
memory and fed to quadratic license-matcher regexes
                 Key: RAT-589
                 URL: https://issues.apache.org/jira/browse/RAT-589
             Project: Apache RAT
          Issue Type: Bug
    Affects Versions: 0.18
            Reporter: Philipp Ottlinger


Header line limit is dead code — whole files buffered in memory and fed to 
quadratic license-matcher regexes

in apache-rat-core/src/main/java/org/apache/rat/analysis/HeaderCheckWorker.java

readHeader() declared headerLinesRead, tested it in the loop condition 
(headerLinesRead < numberOfLines), but never incremented it, so the documented 
DEFAULT_NUMBER_OF_RETAINED_HEADER_LINES=50 bound was dead code and every 
scanned file was buffered in full (twice: raw + pruned copy) and fed to the 
SPDX/copyright matcher regexes. The one-line fix (headerLinesRead++ in the loop 
body) restores the documented behavior; with the bound live, the downstream 
quadratic regex costs (SPDXMatcherFactory GROUP_SELECTOR greedy .* prefix, 
CopyrightMatcher find()/start()==0) are capped to 50 lines of input per file. 
The bound is already configurable: the HeaderCheckWorker(generatedMatcher, 
reader, numberOfRetainedHeaderLine, licenses, document) constructor takes the 
line count and the convenience constructor passes the documented default of 50; 
no new option plumbing needed.

This issue was found using Claude agents to study the security of open-source 
projects (finder)



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to