소스 검색

Validate stdout paths

This should prevent breaking out of the search to grep /etc/shadow or similar shenanigans.
master
JustAnotherArchivist 3 년 전
부모
커밋
26aea9d827
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. +3
    -1
      irclog.py

+ 3
- 1
irclog.py 파일 보기

@@ -877,12 +877,14 @@ class WebServer:
yield (path, line)

def _stdout_with_path(self, stdout):
# Process grep output with --with-filenames, --null, and --line-number into (path, line) tuples; this blindly assumes the expected directory structure of '.../path/YYYY-MM.log'.
# Process grep output with --with-filenames, --null, and --line-number into (path, line) tuples.
# Lines are sorted by timestamp, filename, and line number to ensure a consistent and chronological order.
out = []
for line in stdout.decode('utf-8').splitlines():
fn, line = line.split('\0', 1)
assert fn.startswith(self.config['storage']['path'] + '/') and fn.count('/', len(self.config['storage']['path']) + 1) == 1
_, path, _ = fn.rsplit('/', 2)
assert path in self._paths
ln, line = line.split(':', 1)
ln = int(ln)
ts = float(line.split(' ', 1)[0])


불러오는 중...
취소
저장