압축파일 미리보기 디코더와 제한된 해제를 구현한다
- 작성자
- 시로사키 하나
- 작성 시각
- 커밋
5557fb0216b6771d1a9b2f1edf9d956e096d5e50- 부모
- bda9192
변경된 파일 23개
+1,744-21| @@ -2,6 +2,12 @@ | ||
| 2 | 2 | # It is not intended for manual editing. |
| 3 | 3 | version = 4 |
| 4 | 4 | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "adler2" | |
| 7 | 추가: version = "2.0.1" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" | |
| 10 | 추가: | |
| 5 | 11 | [[package]] |
| 6 | 12 | name = "aes" |
| 7 | 13 | version = "0.8.4" |
| @@ -14,6 +20,12 @@ dependencies = [ | ||
| 14 | 20 | "zeroize", |
| 15 | 21 | ] |
| 16 | 22 | |
| 23 | 추가: [[package]] | |
| 24 | 추가: name = "bitflags" | |
| 25 | 추가: version = "2.13.2" | |
| 26 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 27 | 추가: checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" | |
| 28 | 추가: | |
| 17 | 29 | [[package]] |
| 18 | 30 | name = "block-buffer" |
| 19 | 31 | version = "0.10.4" |
| @@ -81,6 +93,15 @@ dependencies = [ | ||
| 81 | 93 | "libc", |
| 82 | 94 | ] |
| 83 | 95 | |
| 96 | 추가: [[package]] | |
| 97 | 추가: name = "crc32fast" | |
| 98 | 추가: version = "1.5.5" | |
| 99 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 100 | 추가: checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" | |
| 101 | 추가: dependencies = [ | |
| 102 | 추가: "cfg-if", | |
| 103 | 추가: ] | |
| 104 | 추가: | |
| 84 | 105 | [[package]] |
| 85 | 106 | name = "crypto-common" |
| 86 | 107 | version = "0.1.7" |
| @@ -122,6 +143,26 @@ dependencies = [ | ||
| 122 | 143 | "crypto-common 0.2.2", |
| 123 | 144 | ] |
| 124 | 145 | |
| 146 | 추가: [[package]] | |
| 147 | 추가: name = "fdeflate" | |
| 148 | 추가: version = "0.3.7" | |
| 149 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 150 | 추가: checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" | |
| 151 | 추가: dependencies = [ | |
| 152 | 추가: "simd-adler32", | |
| 153 | 추가: ] | |
| 154 | 추가: | |
| 155 | 추가: [[package]] | |
| 156 | 추가: name = "flate2" | |
| 157 | 추가: version = "1.1.11" | |
| 158 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 159 | 추가: checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" | |
| 160 | 추가: dependencies = [ | |
| 161 | 추가: "crc32fast", | |
| 162 | 추가: "miniz_oxide 0.9.1", | |
| 163 | 추가: "zlib-rs", | |
| 164 | 추가: ] | |
| 165 | 추가: | |
| 125 | 166 | [[package]] |
| 126 | 167 | name = "generic-array" |
| 127 | 168 | version = "0.14.7" |
| @@ -180,6 +221,26 @@ dependencies = [ | ||
| 180 | 221 | "sha2 0.11.1", |
| 181 | 222 | ] |
| 182 | 223 | |
| 224 | 추가: [[package]] | |
| 225 | 추가: name = "miniz_oxide" | |
| 226 | 추가: version = "0.8.9" | |
| 227 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 228 | 추가: checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" | |
| 229 | 추가: dependencies = [ | |
| 230 | 추가: "adler2", | |
| 231 | 추가: "simd-adler32", | |
| 232 | 추가: ] | |
| 233 | 추가: | |
| 234 | 추가: [[package]] | |
| 235 | 추가: name = "miniz_oxide" | |
| 236 | 추가: version = "0.9.1" | |
| 237 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 238 | 추가: checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" | |
| 239 | 추가: dependencies = [ | |
| 240 | 추가: "adler2", | |
| 241 | 추가: "simd-adler32", | |
| 242 | 추가: ] | |
| 243 | 추가: | |
| 183 | 244 | [[package]] |
| 184 | 245 | name = "pbkdf2" |
| 185 | 246 | version = "0.12.2" |
| @@ -190,6 +251,19 @@ dependencies = [ | ||
| 190 | 251 | "hmac", |
| 191 | 252 | ] |
| 192 | 253 | |
| 254 | 추가: [[package]] | |
| 255 | 추가: name = "png" | |
| 256 | 추가: version = "0.18.1" | |
| 257 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 258 | 추가: checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" | |
| 259 | 추가: dependencies = [ | |
| 260 | 추가: "bitflags", | |
| 261 | 추가: "crc32fast", | |
| 262 | 추가: "fdeflate", | |
| 263 | 추가: "flate2", | |
| 264 | 추가: "miniz_oxide 0.8.9", | |
| 265 | 추가: ] | |
| 266 | 추가: | |
| 193 | 267 | [[package]] |
| 194 | 268 | name = "sha1" |
| 195 | 269 | version = "0.10.7" |
| @@ -223,6 +297,12 @@ dependencies = [ | ||
| 223 | 297 | "digest 0.11.3", |
| 224 | 298 | ] |
| 225 | 299 | |
| 300 | 추가: [[package]] | |
| 301 | 추가: name = "simd-adler32" | |
| 302 | 추가: version = "0.3.10" | |
| 303 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 304 | 추가: checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" | |
| 305 | 추가: | |
| 226 | 306 | [[package]] |
| 227 | 307 | name = "subtle" |
| 228 | 308 | version = "2.6.1" |
| @@ -256,11 +336,14 @@ dependencies = [ | ||
| 256 | 336 | "hmac", |
| 257 | 337 | "lzma-rust2", |
| 258 | 338 | "pbkdf2", |
| 339 | 추가: "png", | |
| 259 | 340 | "sha1", |
| 260 | 341 | "sha2 0.10.9", |
| 261 | 342 | "subtle", |
| 262 | 343 | "zeroize", |
| 263 | 344 | "zlib-rs", |
| 345 | 추가: "zune-core", | |
| 346 | 추가: "zune-jpeg", | |
| 264 | 347 | ] |
| 265 | 348 | |
| 266 | 349 | [[package]] |
| @@ -268,3 +351,18 @@ name = "zlib-rs" | ||
| 268 | 351 | version = "0.6.8" |
| 269 | 352 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 270 | 353 | checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| 354 | 추가: | |
| 355 | 추가: [[package]] | |
| 356 | 추가: name = "zune-core" | |
| 357 | 추가: version = "0.5.3" | |
| 358 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 359 | 추가: checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" | |
| 360 | 추가: | |
| 361 | 추가: [[package]] | |
| 362 | 추가: name = "zune-jpeg" | |
| 363 | 추가: version = "0.5.15" | |
| 364 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 365 | 추가: checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" | |
| 366 | 추가: dependencies = [ | |
| 367 | 추가: "zune-core", | |
| 368 | 추가: ] |
| @@ -7,6 +7,9 @@ publish = false | ||
| 7 | 7 | autotests = false |
| 8 | 8 | |
| 9 | 9 | [dependencies] |
| 10 | 추가: png = "=0.18.1" | |
| 11 | 추가: zune-jpeg = { version = "=0.5.15", default-features = false, features = ["std"] } | |
| 12 | 추가: zune-core = { version = "=0.5.3", default-features = false, features = ["std"] } | |
| 10 | 13 | bzip2 = "=0.6.1" |
| 11 | 14 | lzma-rust2 = { version = "=0.25.0", default-features = false, features = ["std", "xz"] } |
| 12 | 15 | aes = { version = "=0.8.4", features = ["zeroize"] } |
| @@ -132,7 +132,7 @@ Python 표준 bz2, lzma와 tarfile로 독립 생성 및 해제한 결과의 SHA2 | ||
| 132 | 132 | |
| 133 | 133 | ## 미리보기 계약 |
| 134 | 134 | |
| 135 | 삭제: 상태: frontend와 backend의 계약 합의가 완료되었다. protocol.rs와 wire.rs에 공용 타입, 전송 규칙과 상한 검증을 반영했다. 작업자 디코더와 앱 연동 전이므로 미리보기 실행은 UnsupportedFeature로 끝나며 결과를 생성하지 않는다. 확정된 범위는 [PLANS 8.7](../../docs/PLANS.md)을 따른다. 8.8 분할 7z는 이 구현에서 제외한다. | |
| 135 | 추가: 상태: frontend와 backend의 계약 합의가 완료되었다. protocol.rs와 wire.rs에 공용 타입, 전송 규칙과 상한 검증을 반영했다. 작업자의 제한된 해제와 PNG/JPEG 디코더를 연결했다. 실제 압축파일을 사용하는 운영체제별 화면 검증과 독립 리뷰는 완료 전이다. 확정된 범위는 [PLANS 8.7](../../docs/PLANS.md)을 따른다. 8.8 분할 7z는 이 구현에서 제외한다. | |
| 136 | 136 | |
| 137 | 137 | ### 요청과 수명 |
| 138 | 138 | |
| @@ -166,9 +166,12 @@ Python 표준 bz2, lzma와 tarfile로 독립 생성 및 해제한 결과의 SHA2 | ||
| 166 | 166 | - 선택 항목 해제 후 원본 바이트는 텍스트 1 MiB, 이미지 8 MiB 이하다. 실제 읽는 양에도 같은 상한을 적용하며 차원과 픽셀 수를 할당 전에 검사한다. APNG, 다른 애니메이션, 미지원 형식은 제외한다. 손상 입력을 복구하거나 부분 디코딩으로 성공 처리하지 않는다. |
| 167 | 167 | - UnsupportedFormat/UnsupportedFeature는 형식/확장자 불일치와 미지원, Integrity는 잘못된 UTF-8과 손상, Limit는 바이트/픽셀 또는 공통 자원 상한을 뜻한다. SourceChanged, WrongPassword와 기존 I/O/Protocol 오류는 유지한다. 앱은 미리보기 Limit에 고유 상한 확대를 제안하지 않고 일반 해제를 별도 사용자 동작으로 안내한다. |
| 168 | 168 | |
| 169 | 삭제: ### 디코더 후보와 담당 | |
| 169 | 추가: ### 디코더와 담당 | |
| 170 | 170 | |
| 171 | 삭제: - PNG는 png 0.18.1(MIT OR Apache-2.0), JPEG는 zune-jpeg 0.5.15와 zune-core(MIT OR Apache-2.0 OR Zlib)의 직접 사용을 우선 검토한다. MIT 또는 Apache-2.0 조건을 선택하고 순수 Rust 기능만 사용한다. 공통 image 래퍼의 기본 관대한 JPEG 처리 대신 strict 디코딩과 치수/출력 제어를 직접 설정할 수 있다는 이유다. 버전과 실제 활성 기능은 구현 시 잠금 파일로 고정하고 권고 적용성을 대조한다. | |
| 171 | 추가: - PNG는 png 0.18.1(MIT OR Apache-2.0), JPEG는 zune-jpeg 0.5.15와 zune-core 0.5.3(MIT OR Apache-2.0 OR Zlib)을 직접 사용하며 모두 MIT 조건을 선택한다. zune는 std 기능만 켜고 순수 Rust 디코더를 사용한다. strict 모드, 입력/출력 길이와 치수를 직접 제어하기 위해 공통 image 래퍼 대신 선택했다. packaging/licenses.py에서 선택한 MIT와 체크섬을 대조한 라이선스 원문을 배포 고지에 포함한다. | |
| 172 | 추가: - PNG는 모든 청크 CRC와 마지막 IEND를 검증하고 APNG를 거부한다. 텍스트와 ICC 메타데이터의 추가 해독은 끄고 16비트/팔레트/회색조를 RGBA8로 정규화한다. JPEG는 헤더와 스캔 경계를 먼저 확인해 단일 8비트 baseline/progressive 프레임만 해독한다. 회색조와 CMYK도 RGB 해독 뒤 같은 결과 버퍼에서 불투명 RGBA8로 변환한다. 산술 부호화, lossless JPEG와 MPO는 지원하지 않는다. | |
| 173 | 추가: - ZIP은 선택 항목만 해제하며 7z는 선택 항목이 속한 solid 블록 전체를 무결성 검증한다. TAR 계열과 GZip 컨테이너 해독, solid 블록 및 메타데이터에는 기존 공통 예산과 임시 공간 감시를 적용한다. 선택 항목을 결과 버퍼로 읽는 양은 텍스트/이미지 고유 상한을 넘지 않는다. PNG 입력 읽기, 변환 행과 결과 청크마다 취소를 확인한다. JPEG 라이브러리 호출은 전후에 취소를 확인하고 기존 자식 종료/회수 정책을 유지한다. | |
| 174 | 추가: - 2026-11-14 공개 RustSec DB의 crates 트리 86148de9e400d7460a03b8089d1de31af2d1e6c3에서 추가 의존성 10종 이름의 권고 기록이 없는 것을 확인했다. 이 확인은 전체 잠금 파일의 자동 감사나 취약점 부재를 보장하지 않는다. | |
| 172 | 175 | - PNG의 제한된 Decoder와 행/프레임 API는 [공식 문서](https://docs.rs/png/0.18.1/png/)를 참고한다. 라이브러리 내부 할당 제한을 작업자 전체 RSS의 강제 상한으로 표현하지 않는다. 엄격한 항목 길이, 치수와 결과 길이 검사를 별도로 적용한다. |
| 173 | 176 | - backend는 작업자 protocol.rs, wire.rs, runtime 및 디코더, 작업자 시험과 packaging/licenses.py 고지를 맡는다. frontend는 앱 재조립/전송 제어, 화면과 앱 시험, --ui-scenario 및 가이드를 맡는다. 같은 원격 브랜치는 양쪽 결과를 확인하며 순차 갱신하고 공용 타입 변경은 이 계약 합의 후 backend가 반영한다. |
| 174 | 177 | - 시험은 바이트/치수/픽셀 경계, UTF-8 청크 경계와 BOM, 형식 불일치/APNG/손상, 암호와 solid 예산, malformed/순서/중복/초과 전송, 64개 큐 역압과 디코딩 및 전송 중 취소, 늦은 완료 폐기와 정리 및 원본 해시 보존을 포함한다. |
| @@ -6,6 +6,7 @@ mod crypto; | ||
| 6 | 6 | pub mod filesystem; |
| 7 | 7 | mod lzma; |
| 8 | 8 | mod parent; |
| 9 | 추가: mod preview; | |
| 9 | 10 | pub mod protocol; |
| 10 | 11 | pub mod resources; |
| 11 | 12 | pub mod runtime; |
| @@ -0,0 +1,348 @@ | ||
| 1 | 추가: use crate::{protocol::*, resources::Monitor}; | |
| 2 | 추가: use std::io::{self, BufRead, Cursor, Read, Seek, SeekFrom}; | |
| 3 | 추가: use zlib_rs::crc32::crc32; | |
| 4 | 추가: use zune_core::{bytestream::ZCursor, colorspace::ColorSpace, options::DecoderOptions}; | |
| 5 | 추가: | |
| 6 | 추가: type Result<T> = std::result::Result<T, ErrorCode>; | |
| 7 | 추가: | |
| 8 | 추가: #[derive(Clone, Copy)] | |
| 9 | 추가: pub(crate) enum Kind { | |
| 10 | 추가: Text, | |
| 11 | 추가: Png, | |
| 12 | 추가: Jpeg, | |
| 13 | 추가: } | |
| 14 | 추가: impl Kind { | |
| 15 | 추가: pub fn from_name(name: &str) -> Result<Self> { | |
| 16 | 추가: match name | |
| 17 | 추가: .rsplit_once('.') | |
| 18 | 추가: .map(|(_, ext)| ext.to_ascii_lowercase()) | |
| 19 | 추가: .as_deref() | |
| 20 | 추가: { | |
| 21 | 추가: Some("txt" | "md" | "log" | "csv" | "json") => Ok(Self::Text), | |
| 22 | 추가: Some("png") => Ok(Self::Png), | |
| 23 | 추가: Some("jpg" | "jpeg") => Ok(Self::Jpeg), | |
| 24 | 추가: _ => Err(ErrorCode::UnsupportedFeature), | |
| 25 | 추가: } | |
| 26 | 추가: } | |
| 27 | 추가: pub fn limit(self) -> u64 { | |
| 28 | 추가: match self { | |
| 29 | 추가: Self::Text => MAX_PREVIEW_TEXT_BYTES, | |
| 30 | 추가: Self::Png | Self::Jpeg => MAX_PREVIEW_IMAGE_BYTES, | |
| 31 | 추가: } | |
| 32 | 추가: } | |
| 33 | 추가: } | |
| 34 | 추가: fn rgba_info(entry_id: u32, width: u32, height: u32) -> Result<PreviewInfo> { | |
| 35 | 추가: if width == 0 || height == 0 { | |
| 36 | 추가: return Err(ErrorCode::Integrity); | |
| 37 | 추가: } | |
| 38 | 추가: let total_bytes = u64::from(width) | |
| 39 | 추가: .checked_mul(u64::from(height)) | |
| 40 | 추가: .and_then(|n| n.checked_mul(4)) | |
| 41 | 추가: .ok_or(ErrorCode::Limit)?; | |
| 42 | 추가: let info = PreviewInfo { | |
| 43 | 추가: entry_id, | |
| 44 | 추가: format: PreviewFormat::Rgba8, | |
| 45 | 추가: total_bytes, | |
| 46 | 추가: width, | |
| 47 | 추가: height, | |
| 48 | 추가: }; | |
| 49 | 추가: if !info.valid() { | |
| 50 | 추가: return Err(ErrorCode::Limit); | |
| 51 | 추가: } | |
| 52 | 추가: Ok(info) | |
| 53 | 추가: } | |
| 54 | 추가: fn buffer(length: usize) -> Result<Vec<u8>> { | |
| 55 | 추가: let mut bytes = Vec::new(); | |
| 56 | 추가: bytes | |
| 57 | 추가: .try_reserve_exact(length) | |
| 58 | 추가: .map_err(|_| ErrorCode::Limit)?; | |
| 59 | 추가: bytes.resize(length, 0); | |
| 60 | 추가: Ok(bytes) | |
| 61 | 추가: } | |
| 62 | 추가: pub(crate) fn decode( | |
| 63 | 추가: kind: Kind, | |
| 64 | 추가: entry_id: u32, | |
| 65 | 추가: mut source: Vec<u8>, | |
| 66 | 추가: check: &mut impl Monitor, | |
| 67 | 추가: ) -> Result<(PreviewInfo, Vec<u8>)> { | |
| 68 | 추가: check.check()?; | |
| 69 | 추가: if source.len() as u64 > kind.limit() { | |
| 70 | 추가: return Err(ErrorCode::Limit); | |
| 71 | 추가: } | |
| 72 | 추가: let result = match kind { | |
| 73 | 추가: Kind::Text => { | |
| 74 | 추가: std::str::from_utf8(&source).map_err(|_| ErrorCode::Integrity)?; | |
| 75 | 추가: if source.starts_with(&[0xef, 0xbb, 0xbf]) { | |
| 76 | 추가: source.drain(..3); | |
| 77 | 추가: } | |
| 78 | 추가: Ok(( | |
| 79 | 추가: PreviewInfo { | |
| 80 | 추가: entry_id, | |
| 81 | 추가: format: PreviewFormat::Utf8Text, | |
| 82 | 추가: total_bytes: source.len() as u64, | |
| 83 | 추가: width: 0, | |
| 84 | 추가: height: 0, | |
| 85 | 추가: }, | |
| 86 | 추가: source, | |
| 87 | 추가: )) | |
| 88 | 추가: } | |
| 89 | 추가: Kind::Png => png(entry_id, &source, check), | |
| 90 | 추가: Kind::Jpeg => jpeg(entry_id, &source, check), | |
| 91 | 추가: }; | |
| 92 | 추가: check.activity()?; | |
| 93 | 추가: result | |
| 94 | 추가: } | |
| 95 | 추가: struct Input<'a, M> { | |
| 96 | 추가: bytes: Cursor<&'a [u8]>, | |
| 97 | 추가: check: &'a mut M, | |
| 98 | 추가: } | |
| 99 | 추가: impl<M: Monitor> Read for Input<'_, M> { | |
| 100 | 추가: fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> { | |
| 101 | 추가: self.check | |
| 102 | 추가: .check() | |
| 103 | 추가: .map_err(|_| io::Error::other("preview interrupted"))?; | |
| 104 | 추가: let length = self.bytes.read(bytes)?; | |
| 105 | 추가: if length != 0 { | |
| 106 | 추가: self.check | |
| 107 | 추가: .activity() | |
| 108 | 추가: .map_err(|_| io::Error::other("preview interrupted"))?; | |
| 109 | 추가: } | |
| 110 | 추가: Ok(length) | |
| 111 | 추가: } | |
| 112 | 추가: } | |
| 113 | 추가: impl<M: Monitor> BufRead for Input<'_, M> { | |
| 114 | 추가: fn fill_buf(&mut self) -> io::Result<&[u8]> { | |
| 115 | 추가: self.check | |
| 116 | 추가: .check() | |
| 117 | 추가: .map_err(|_| io::Error::other("preview interrupted"))?; | |
| 118 | 추가: self.bytes.fill_buf() | |
| 119 | 추가: } | |
| 120 | 추가: fn consume(&mut self, length: usize) { | |
| 121 | 추가: self.bytes.consume(length); | |
| 122 | 추가: } | |
| 123 | 추가: } | |
| 124 | 추가: impl<M: Monitor> Seek for Input<'_, M> { | |
| 125 | 추가: fn seek(&mut self, position: SeekFrom) -> io::Result<u64> { | |
| 126 | 추가: self.check | |
| 127 | 추가: .check() | |
| 128 | 추가: .map_err(|_| io::Error::other("preview interrupted"))?; | |
| 129 | 추가: self.bytes.seek(position) | |
| 130 | 추가: } | |
| 131 | 추가: } | |
| 132 | 추가: fn png(entry_id: u32, source: &[u8], check: &mut impl Monitor) -> Result<(PreviewInfo, Vec<u8>)> { | |
| 133 | 추가: if !source.starts_with(b"\x89PNG\r\n\x1a\n") { | |
| 134 | 추가: return Err(ErrorCode::UnsupportedFormat); | |
| 135 | 추가: } | |
| 136 | 추가: let mut at = 8usize; | |
| 137 | 추가: let mut ended = false; | |
| 138 | 추가: while at < source.len() { | |
| 139 | 추가: check.check()?; | |
| 140 | 추가: let header = source.get(at..at + 8).ok_or(ErrorCode::Integrity)?; | |
| 141 | 추가: let length = u32::from_be_bytes(header[..4].try_into().unwrap()) as usize; | |
| 142 | 추가: let end = at | |
| 143 | 추가: .checked_add(12) | |
| 144 | 추가: .and_then(|n| n.checked_add(length)) | |
| 145 | 추가: .filter(|n| *n <= source.len()) | |
| 146 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 147 | 추가: if crc32(0, &source[at + 4..end - 4]) | |
| 148 | 추가: != u32::from_be_bytes(source[end - 4..end].try_into().unwrap()) | |
| 149 | 추가: { | |
| 150 | 추가: return Err(ErrorCode::Integrity); | |
| 151 | 추가: } | |
| 152 | 추가: if at == 8 && (&header[4..] != b"IHDR" || length != 13) { | |
| 153 | 추가: return Err(ErrorCode::Integrity); | |
| 154 | 추가: } | |
| 155 | 추가: if matches!(&header[4..], b"acTL" | b"fcTL" | b"fdAT") { | |
| 156 | 추가: return Err(ErrorCode::UnsupportedFeature); | |
| 157 | 추가: } | |
| 158 | 추가: if &header[4..] == b"IEND" { | |
| 159 | 추가: if length != 0 || end != source.len() { | |
| 160 | 추가: return Err(ErrorCode::Integrity); | |
| 161 | 추가: } | |
| 162 | 추가: ended = true; | |
| 163 | 추가: } | |
| 164 | 추가: at = end; | |
| 165 | 추가: check.activity()?; | |
| 166 | 추가: } | |
| 167 | 추가: if !ended { | |
| 168 | 추가: return Err(ErrorCode::Integrity); | |
| 169 | 추가: } | |
| 170 | 추가: let mut decoder = png::Decoder::new_with_limits( | |
| 171 | 추가: Input { | |
| 172 | 추가: bytes: Cursor::new(source), | |
| 173 | 추가: check, | |
| 174 | 추가: }, | |
| 175 | 추가: png::Limits { | |
| 176 | 추가: bytes: 128 * 1024 * 1024, | |
| 177 | 추가: }, | |
| 178 | 추가: ); | |
| 179 | 추가: decoder.set_ignore_text_chunk(true); | |
| 180 | 추가: decoder.set_ignore_iccp_chunk(true); | |
| 181 | 추가: decoder.set_transformations(png::Transformations::EXPAND | png::Transformations::STRIP_16); | |
| 182 | 추가: let header = decoder | |
| 183 | 추가: .read_header_info() | |
| 184 | 추가: .map_err(|_| ErrorCode::Integrity)?; | |
| 185 | 추가: let info = rgba_info(entry_id, header.width, header.height)?; | |
| 186 | 추가: let mut reader = decoder.read_info().map_err(|_| ErrorCode::Integrity)?; | |
| 187 | 추가: let length = reader | |
| 188 | 추가: .output_buffer_size() | |
| 189 | 추가: .filter(|n| *n as u64 <= info.total_bytes) | |
| 190 | 추가: .ok_or(ErrorCode::Limit)?; | |
| 191 | 추가: let mut raw = buffer(length)?; | |
| 192 | 추가: let decoded = reader | |
| 193 | 추가: .next_frame(&mut raw) | |
| 194 | 추가: .map_err(|_| ErrorCode::Integrity)?; | |
| 195 | 추가: reader.finish().map_err(|_| ErrorCode::Integrity)?; | |
| 196 | 추가: drop(reader); | |
| 197 | 추가: check.activity()?; | |
| 198 | 추가: if decoded.width != info.width | |
| 199 | 추가: || decoded.height != info.height | |
| 200 | 추가: || decoded.bit_depth != png::BitDepth::Eight | |
| 201 | 추가: { | |
| 202 | 추가: return Err(ErrorCode::Integrity); | |
| 203 | 추가: } | |
| 204 | 추가: raw.truncate(decoded.buffer_size()); | |
| 205 | 추가: let channels = match decoded.color_type { | |
| 206 | 추가: png::ColorType::Grayscale => 1, | |
| 207 | 추가: png::ColorType::GrayscaleAlpha => 2, | |
| 208 | 추가: png::ColorType::Rgb => 3, | |
| 209 | 추가: png::ColorType::Rgba => 4, | |
| 210 | 추가: _ => return Err(ErrorCode::UnsupportedFeature), | |
| 211 | 추가: }; | |
| 212 | 추가: if raw.len() != info.width as usize * info.height as usize * channels { | |
| 213 | 추가: return Err(ErrorCode::Integrity); | |
| 214 | 추가: } | |
| 215 | 추가: if channels == 4 { | |
| 216 | 추가: return Ok((info, raw)); | |
| 217 | 추가: } | |
| 218 | 추가: let mut rgba = buffer(info.total_bytes as usize)?; | |
| 219 | 추가: for (source, target) in raw | |
| 220 | 추가: .chunks_exact(info.width as usize * channels) | |
| 221 | 추가: .zip(rgba.chunks_exact_mut(info.width as usize * 4)) | |
| 222 | 추가: { | |
| 223 | 추가: check.activity()?; | |
| 224 | 추가: for (pixel, out) in source | |
| 225 | 추가: .chunks_exact(channels) | |
| 226 | 추가: .zip(target.chunks_exact_mut(4)) | |
| 227 | 추가: { | |
| 228 | 추가: match channels { | |
| 229 | 추가: 1 => out.copy_from_slice(&[pixel[0], pixel[0], pixel[0], 255]), | |
| 230 | 추가: 2 => out.copy_from_slice(&[pixel[0], pixel[0], pixel[0], pixel[1]]), | |
| 231 | 추가: 3 => out.copy_from_slice(&[pixel[0], pixel[1], pixel[2], 255]), | |
| 232 | 추가: _ => unreachable!(), | |
| 233 | 추가: } | |
| 234 | 추가: } | |
| 235 | 추가: } | |
| 236 | 추가: Ok((info, rgba)) | |
| 237 | 추가: } | |
| 238 | 추가: fn jpeg_info(entry_id: u32, source: &[u8], check: &mut impl Monitor) -> Result<PreviewInfo> { | |
| 239 | 추가: let mut at = 2usize; | |
| 240 | 추가: let mut scanning = false; | |
| 241 | 추가: let mut info = None; | |
| 242 | 추가: let mut seen_scan = false; | |
| 243 | 추가: while at < source.len() { | |
| 244 | 추가: check.check()?; | |
| 245 | 추가: if scanning { | |
| 246 | 추가: at += source[at..] | |
| 247 | 추가: .iter() | |
| 248 | 추가: .position(|byte| *byte == 0xff) | |
| 249 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 250 | 추가: } | |
| 251 | 추가: if source[at] != 0xff { | |
| 252 | 추가: return Err(ErrorCode::Integrity); | |
| 253 | 추가: } | |
| 254 | 추가: while source.get(at) == Some(&0xff) { | |
| 255 | 추가: at += 1; | |
| 256 | 추가: } | |
| 257 | 추가: let marker = *source.get(at).ok_or(ErrorCode::Integrity)?; | |
| 258 | 추가: at += 1; | |
| 259 | 추가: match marker { | |
| 260 | 추가: 0 | 0xd0..=0xd7 if scanning => continue, | |
| 261 | 추가: 0xd9 if at == source.len() && seen_scan => return info.ok_or(ErrorCode::Integrity), | |
| 262 | 추가: 0 | 0xd0..=0xd9 => return Err(ErrorCode::Integrity), | |
| 263 | 추가: 1 => continue, | |
| 264 | 추가: _ => {} | |
| 265 | 추가: } | |
| 266 | 추가: let length = source.get(at..at + 2).ok_or(ErrorCode::Integrity)?; | |
| 267 | 추가: let length = u16::from_be_bytes(length.try_into().unwrap()) as usize; | |
| 268 | 추가: let end = at | |
| 269 | 추가: .checked_add(length) | |
| 270 | 추가: .filter(|n| length >= 2 && *n <= source.len()) | |
| 271 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 272 | 추가: let body = &source[at + 2..end]; | |
| 273 | 추가: if matches!(marker, 0xc0..=0xcf) && !matches!(marker, 0xc4 | 0xc8 | 0xcc) { | |
| 274 | 추가: if info.is_some() || body.len() < 6 { | |
| 275 | 추가: return Err(ErrorCode::Integrity); | |
| 276 | 추가: } | |
| 277 | 추가: if !matches!(marker, 0xc0 | 0xc2) || body[0] != 8 { | |
| 278 | 추가: return Err(ErrorCode::UnsupportedFeature); | |
| 279 | 추가: } | |
| 280 | 추가: info = Some(rgba_info( | |
| 281 | 추가: entry_id, | |
| 282 | 추가: u32::from(u16::from_be_bytes(body[3..5].try_into().unwrap())), | |
| 283 | 추가: u32::from(u16::from_be_bytes(body[1..3].try_into().unwrap())), | |
| 284 | 추가: )?); | |
| 285 | 추가: } | |
| 286 | 추가: if marker == 0xe2 && body.starts_with(b"MPF\0") { | |
| 287 | 추가: return Err(ErrorCode::UnsupportedFeature); | |
| 288 | 추가: } | |
| 289 | 추가: scanning = marker == 0xda; | |
| 290 | 추가: seen_scan |= scanning; | |
| 291 | 추가: at = end; | |
| 292 | 추가: check.activity()?; | |
| 293 | 추가: } | |
| 294 | 추가: Err(ErrorCode::Integrity) | |
| 295 | 추가: } | |
| 296 | 추가: fn jpeg_error(error: zune_jpeg::errors::DecodeErrors) -> ErrorCode { | |
| 297 | 추가: match error { | |
| 298 | 추가: zune_jpeg::errors::DecodeErrors::LargeDimensions(_) => ErrorCode::Limit, | |
| 299 | 추가: zune_jpeg::errors::DecodeErrors::Unsupported(_) => ErrorCode::UnsupportedFeature, | |
| 300 | 추가: _ => ErrorCode::Integrity, | |
| 301 | 추가: } | |
| 302 | 추가: } | |
| 303 | 추가: fn jpeg(entry_id: u32, source: &[u8], check: &mut impl Monitor) -> Result<(PreviewInfo, Vec<u8>)> { | |
| 304 | 추가: if !source.starts_with(&[0xff, 0xd8]) { | |
| 305 | 추가: return Err(ErrorCode::UnsupportedFormat); | |
| 306 | 추가: } | |
| 307 | 추가: if !source.ends_with(&[0xff, 0xd9]) { | |
| 308 | 추가: return Err(ErrorCode::Integrity); | |
| 309 | 추가: } | |
| 310 | 추가: let expected = jpeg_info(entry_id, source, check)?; | |
| 311 | 추가: let options = DecoderOptions::new_safe() | |
| 312 | 추가: .set_strict_mode(true) | |
| 313 | 추가: .set_max_width(MAX_PREVIEW_DIMENSION as usize) | |
| 314 | 추가: .set_max_height(MAX_PREVIEW_DIMENSION as usize) | |
| 315 | 추가: .jpeg_set_max_scans(100) | |
| 316 | 추가: .jpeg_set_out_colorspace(ColorSpace::RGB); | |
| 317 | 추가: let mut decoder = zune_jpeg::JpegDecoder::new_with_options(ZCursor::new(source), options); | |
| 318 | 추가: decoder.decode_headers().map_err(jpeg_error)?; | |
| 319 | 추가: let header = decoder.info().ok_or(ErrorCode::Integrity)?; | |
| 320 | 추가: let info = rgba_info(entry_id, u32::from(header.width), u32::from(header.height))?; | |
| 321 | 추가: let rgb_bytes = (info.total_bytes / 4 * 3) as usize; | |
| 322 | 추가: if info != expected || decoder.output_buffer_size() != Some(rgb_bytes) { | |
| 323 | 추가: return Err(ErrorCode::Integrity); | |
| 324 | 추가: } | |
| 325 | 추가: let mut rgba = buffer(info.total_bytes as usize)?; | |
| 326 | 추가: decoder | |
| 327 | 추가: .decode_into(&mut rgba[..rgb_bytes]) | |
| 328 | 추가: .map_err(jpeg_error)?; | |
| 329 | 추가: // CMYK의 RGBA 경로를 피하고 같은 버퍼 안에서 불투명 알파를 채움. | |
| 330 | 추가: for row in (0..info.height as usize).rev() { | |
| 331 | 추가: check.activity()?; | |
| 332 | 추가: for column in (0..info.width as usize).rev() { | |
| 333 | 추가: let pixel = row * info.width as usize + column; | |
| 334 | 추가: let rgb = [ | |
| 335 | 추가: rgba[pixel * 3], | |
| 336 | 추가: rgba[pixel * 3 + 1], | |
| 337 | 추가: rgba[pixel * 3 + 2], | |
| 338 | 추가: 255, | |
| 339 | 추가: ]; | |
| 340 | 추가: rgba[pixel * 4..pixel * 4 + 4].copy_from_slice(&rgb); | |
| 341 | 추가: } | |
| 342 | 추가: } | |
| 343 | 추가: Ok((info, rgba)) | |
| 344 | 추가: } | |
| 345 | 추가: | |
| 346 | 추가: #[cfg(test)] | |
| 347 | 추가: #[path = "../../../tests/rust-archive-worker/preview_decode.rs"] | |
| 348 | 추가: mod tests; |
| @@ -352,6 +352,140 @@ impl<W: Write> Job<W> { | ||
| 352 | 352 | } |
| 353 | 353 | Ok(()) |
| 354 | 354 | } |
| 355 | 추가: fn preview( | |
| 356 | 추가: &mut self, | |
| 357 | 추가: archive: NativePath, | |
| 358 | 추가: entry_id: u32, | |
| 359 | 추가: expected: ListId, | |
| 360 | 추가: limits: Limits, | |
| 361 | 추가: ) -> Result<()> { | |
| 362 | 추가: use sha2::{Digest, Sha256}; | |
| 363 | 추가: use std::io::{Read, Seek, SeekFrom}; | |
| 364 | 추가: let path = archive.to_path()?; | |
| 365 | 추가: self.progress(Stage::Read, 0, None, 0)?; | |
| 366 | 추가: let mut snapshot = | |
| 367 | 추가: crate::spool::Snapshot::open_reporting(&path, limits.input, &mut |step| match step { | |
| 368 | 추가: crate::spool::Step::Check => self.check(), | |
| 369 | 추가: crate::spool::Step::Activity => completed(Ok(()), self), | |
| 370 | 추가: crate::spool::Step::Read { bytes, total } => { | |
| 371 | 추가: self.progress(Stage::Read, bytes, Some(total), 0) | |
| 372 | 추가: } | |
| 373 | 추가: })?; | |
| 374 | 추가: if expected.catalog_version != 1 | |
| 375 | 추가: || expected.source_object != snapshot.object | |
| 376 | 추가: || expected.archive_bytes != snapshot.len | |
| 377 | 추가: || expected.archive_sha256 != snapshot.hash | |
| 378 | 추가: { | |
| 379 | 추가: return Err(ErrorCode::SourceChanged); | |
| 380 | 추가: } | |
| 381 | 추가: let mut catalog = crate::streaming::Catalog::open( | |
| 382 | 추가: &mut snapshot.file, | |
| 383 | 추가: snapshot.len, | |
| 384 | 추가: limits, | |
| 385 | 추가: false, | |
| 386 | 추가: None, | |
| 387 | 추가: self, | |
| 388 | 추가: )?; | |
| 389 | 추가: if expected.format != catalog.format { | |
| 390 | 추가: return Err(ErrorCode::SourceChanged); | |
| 391 | 추가: } | |
| 392 | 추가: let entry = catalog | |
| 393 | 추가: .members | |
| 394 | 추가: .get(entry_id as usize) | |
| 395 | 추가: .ok_or(ErrorCode::InvalidRequest)? | |
| 396 | 추가: .entry | |
| 397 | 추가: .clone(); | |
| 398 | 추가: if entry.entry_id != entry_id || entry.kind != EntryKind::File { | |
| 399 | 추가: return Err(ErrorCode::InvalidRequest); | |
| 400 | 추가: } | |
| 401 | 추가: let name = if catalog.format == Format::Gzip { | |
| 402 | 추가: let name = path | |
| 403 | 추가: .file_name() | |
| 404 | 추가: .and_then(|s| s.to_str()) | |
| 405 | 추가: .ok_or(ErrorCode::UnsupportedFeature)?; | |
| 406 | 추가: if !name.to_ascii_lowercase().ends_with(".gz") { | |
| 407 | 추가: return Err(ErrorCode::UnsupportedFeature); | |
| 408 | 추가: } | |
| 409 | 추가: &name[..name.len() - 3] | |
| 410 | 추가: } else { | |
| 411 | 추가: &entry.name | |
| 412 | 추가: }; | |
| 413 | 추가: let kind = crate::preview::Kind::from_name(name)?; | |
| 414 | 추가: if entry.size > kind.limit() { | |
| 415 | 추가: return Err(ErrorCode::Limit); | |
| 416 | 추가: } | |
| 417 | 추가: self.progress(Stage::Decode, 0, Some(entry.size), 0)?; | |
| 418 | 추가: if matches!(catalog.format, Format::Zip | Format::SevenZip) { | |
| 419 | 추가: for attempt in 1..=3 { | |
| 420 | 추가: let secret = if entry.encrypted { | |
| 421 | 추가: Some(self.password(PasswordPurpose::Decrypt, attempt)?) | |
| 422 | 추가: } else { | |
| 423 | 추가: None | |
| 424 | 추가: }; | |
| 425 | 추가: match crate::streaming::Catalog::preview( | |
| 426 | 추가: &mut snapshot.file, | |
| 427 | 추가: snapshot.len, | |
| 428 | 추가: limits, | |
| 429 | 추가: secret.as_ref().map(|s| s.0.as_slice()), | |
| 430 | 추가: entry_id, | |
| 431 | 추가: self, | |
| 432 | 추가: ) { | |
| 433 | 추가: Ok(decoded) => { | |
| 434 | 추가: catalog = decoded; | |
| 435 | 추가: break; | |
| 436 | 추가: } | |
| 437 | 추가: Err(ErrorCode::WrongPassword) if entry.encrypted && attempt < 3 => continue, | |
| 438 | 추가: Err(error) => return Err(error), | |
| 439 | 추가: } | |
| 440 | 추가: } | |
| 441 | 추가: } | |
| 442 | 추가: let mut bytes = Vec::new(); | |
| 443 | 추가: bytes | |
| 444 | 추가: .try_reserve_exact(entry.size as usize) | |
| 445 | 추가: .map_err(|_| ErrorCode::Limit)?; | |
| 446 | 추가: catalog | |
| 447 | 추가: .data | |
| 448 | 추가: .seek(SeekFrom::Start(catalog.offsets[entry_id as usize])) | |
| 449 | 추가: .map_err(crate::space::io_error)?; | |
| 450 | 추가: let mut remaining = entry.size; | |
| 451 | 추가: let mut chunk = [0; 32768]; | |
| 452 | 추가: while remaining != 0 { | |
| 453 | 추가: self.check()?; | |
| 454 | 추가: let length = remaining.min(chunk.len() as u64) as usize; | |
| 455 | 추가: catalog | |
| 456 | 추가: .data | |
| 457 | 추가: .read_exact(&mut chunk[..length]) | |
| 458 | 추가: .map_err(|_| ErrorCode::Integrity)?; | |
| 459 | 추가: bytes.extend_from_slice(&chunk[..length]); | |
| 460 | 추가: remaining -= length as u64; | |
| 461 | 추가: completed(Ok(()), self)?; | |
| 462 | 추가: } | |
| 463 | 추가: let (info, bytes) = crate::preview::decode(kind, entry_id, bytes, self)?; | |
| 464 | 추가: self.check()?; | |
| 465 | 추가: let hash: [u8; 32] = Sha256::digest(&bytes).into(); | |
| 466 | 추가: completed(self.event(Message::PreviewBegin(info)), self)?; | |
| 467 | 추가: for (index, chunk) in bytes.chunks(MAX_PREVIEW_CHUNK_BYTES).enumerate() { | |
| 468 | 추가: self.check()?; | |
| 469 | 추가: completed( | |
| 470 | 추가: self.event(Message::PreviewChunk { | |
| 471 | 추가: entry_id, | |
| 472 | 추가: offset: (index * MAX_PREVIEW_CHUNK_BYTES) as u64, | |
| 473 | 추가: data: chunk.to_vec(), | |
| 474 | 추가: }), | |
| 475 | 추가: self, | |
| 476 | 추가: )?; | |
| 477 | 추가: } | |
| 478 | 추가: self.check()?; | |
| 479 | 추가: completed( | |
| 480 | 추가: self.event(Message::PreviewEnd { | |
| 481 | 추가: entry_id, | |
| 482 | 추가: total_bytes: info.total_bytes, | |
| 483 | 추가: sha256: hash, | |
| 484 | 추가: }), | |
| 485 | 추가: self, | |
| 486 | 추가: )?; | |
| 487 | 추가: Ok(()) | |
| 488 | 추가: } | |
| 355 | 489 | fn run(&mut self, start: Start) -> Result<()> { |
| 356 | 490 | if !start.limits.valid() { |
| 357 | 491 | return Err(ErrorCode::InvalidRequest); |
| @@ -649,8 +783,13 @@ impl<W: Write> Job<W> { | ||
| 649 | 783 | } |
| 650 | 784 | } |
| 651 | 785 | } |
| 652 | 삭제: // 미리보기 실행은 디코더 연결 전까지 지원하지 않음. | |
| 653 | 삭제: Action::Preview { .. } => return Err(ErrorCode::UnsupportedFeature), | |
| 786 | 추가: Action::Preview { | |
| 787 | 추가: archive, | |
| 788 | 추가: entry_id, | |
| 789 | 추가: list_id, | |
| 790 | 추가: } => { | |
| 791 | 추가: self.preview(archive, entry_id, list_id, limits)?; | |
| 792 | 추가: } | |
| 654 | 793 | Action::CreateZip { |
| 655 | 794 | sources, |
| 656 | 795 | output_file, |
| @@ -306,18 +306,28 @@ impl Streams { | ||
| 306 | 306 | input: &mut std::fs::File, |
| 307 | 307 | ranges: &[(u64, u64)], |
| 308 | 308 | output: &mut std::fs::File, |
| 309 | 추가: selected: Option<usize>, | |
| 309 | 310 | check: &mut impl crate::resources::Monitor, |
| 310 | 311 | ) -> Result<()> { |
| 311 | 312 | use std::io::{Read, Seek, SeekFrom, Write}; |
| 312 | 삭제: let total = self.folders.iter().try_fold(0u64, |sum, f| { | |
| 313 | 삭제: crate::resources::completed( | |
| 314 | 삭제: sum.checked_add(f.size as u64).ok_or(ErrorCode::Limit), | |
| 315 | 삭제: check, | |
| 316 | 삭제: ) | |
| 317 | 삭제: })?; | |
| 313 | 추가: let total = self | |
| 314 | 추가: .folders | |
| 315 | 추가: .iter() | |
| 316 | 추가: .enumerate() | |
| 317 | 추가: .filter(|(index, _)| selected.is_none_or(|id| id == *index)) | |
| 318 | 추가: .try_fold(0u64, |sum, (_, f)| { | |
| 319 | 추가: crate::resources::completed( | |
| 320 | 추가: sum.checked_add(f.size as u64).ok_or(ErrorCode::Limit), | |
| 321 | 추가: check, | |
| 322 | 추가: ) | |
| 323 | 추가: })?; | |
| 318 | 324 | crate::space::ensure(output, total)?; |
| 319 | 삭제: for (f, (start, size)) in self.folders.iter().zip(ranges) { | |
| 325 | 추가: for (index, (f, (start, size))) in self.folders.iter().zip(ranges).enumerate() { | |
| 320 | 326 | check.check()?; |
| 327 | 추가: if selected.is_some_and(|id| id != index) { | |
| 328 | 추가: crate::resources::completed(Ok(()), check)?; | |
| 329 | 추가: continue; | |
| 330 | 추가: } | |
| 321 | 331 | let base = output.stream_position().map_err(crate::space::io_error)?; |
| 322 | 332 | check.observe( |
| 323 | 333 | ResourceUsage { |
| @@ -584,6 +594,16 @@ pub(crate) fn open( | ||
| 584 | 594 | limits: Limits, |
| 585 | 595 | decode: bool, |
| 586 | 596 | check: &mut impl crate::resources::Monitor, |
| 597 | 추가: ) -> Result<crate::streaming::Catalog> { | |
| 598 | 추가: open_selected(input, length, limits, decode, None, check) | |
| 599 | 추가: } | |
| 600 | 추가: pub(crate) fn open_selected( | |
| 601 | 추가: input: &mut std::fs::File, | |
| 602 | 추가: length: u64, | |
| 603 | 추가: limits: Limits, | |
| 604 | 추가: decode: bool, | |
| 605 | 추가: selected: Option<u32>, | |
| 606 | 추가: check: &mut impl crate::resources::Monitor, | |
| 587 | 607 | ) -> Result<crate::streaming::Catalog> { |
| 588 | 608 | use std::io::{Read, Seek, SeekFrom}; |
| 589 | 609 | check.check()?; |
| @@ -652,6 +672,7 @@ pub(crate) fn open( | ||
| 652 | 672 | input, |
| 653 | 673 | &ranges, |
| 654 | 674 | &mut data, |
| 675 | 추가: None, | |
| 655 | 676 | &mut crate::resources::MetadataMonitor(check), |
| 656 | 677 | )?; |
| 657 | 678 | data_end = 32u64 |
| @@ -725,9 +746,15 @@ pub(crate) fn open( | ||
| 725 | 746 | let ranges = streams.ranges(input, data_end, check)?; |
| 726 | 747 | let mut at = 0u64; |
| 727 | 748 | let mut ids = stream_indices.into_iter(); |
| 728 | 삭제: for f in &streams.folders { | |
| 749 | 추가: let mut selected_folder = None; | |
| 750 | 추가: for (folder, f) in streams.folders.iter().enumerate() { | |
| 751 | 추가: let base = at; | |
| 729 | 752 | for size in &f.sizes { |
| 730 | 삭제: offsets[ids.next().ok_or(ErrorCode::Integrity)?] = at; | |
| 753 | 추가: let id = ids.next().ok_or(ErrorCode::Integrity)?; | |
| 754 | 추가: offsets[id] = if selected.is_some() { at - base } else { at }; | |
| 755 | 추가: if selected == Some(id as u32) { | |
| 756 | 추가: selected_folder = Some(folder); | |
| 757 | 추가: } | |
| 731 | 758 | at = at.checked_add(*size as u64).ok_or(ErrorCode::Limit)?; |
| 732 | 759 | crate::resources::completed(Ok(()), check)?; |
| 733 | 760 | } |
| @@ -735,8 +762,8 @@ pub(crate) fn open( | ||
| 735 | 762 | if at > limits.output { |
| 736 | 763 | return Err(ErrorCode::Limit); |
| 737 | 764 | } |
| 738 | 삭제: if decode { | |
| 739 | 삭제: streams.decode_file(input, &ranges, &mut data, check)?; | |
| 765 | 추가: if decode && (selected.is_none() || selected_folder.is_some()) { | |
| 766 | 추가: streams.decode_file(input, &ranges, &mut data, selected_folder, check)?; | |
| 740 | 767 | } |
| 741 | 768 | } |
| 742 | 769 | Ok(crate::streaming::Catalog { |
| @@ -53,18 +53,39 @@ impl Catalog { | ||
| 53 | 53 | decode: bool, |
| 54 | 54 | password: Option<&[u8]>, |
| 55 | 55 | check: &mut impl crate::resources::Monitor, |
| 56 | 추가: ) -> Result<Self> { | |
| 57 | 추가: Self::open_selected(source, len, limits, decode, password, None, check) | |
| 58 | 추가: } | |
| 59 | 추가: pub fn preview( | |
| 60 | 추가: source: &mut File, | |
| 61 | 추가: len: u64, | |
| 62 | 추가: limits: Limits, | |
| 63 | 추가: password: Option<&[u8]>, | |
| 64 | 추가: entry_id: u32, | |
| 65 | 추가: check: &mut impl crate::resources::Monitor, | |
| 66 | 추가: ) -> Result<Self> { | |
| 67 | 추가: Self::open_selected(source, len, limits, true, password, Some(entry_id), check) | |
| 68 | 추가: } | |
| 69 | 추가: fn open_selected( | |
| 70 | 추가: source: &mut File, | |
| 71 | 추가: len: u64, | |
| 72 | 추가: limits: Limits, | |
| 73 | 추가: decode: bool, | |
| 74 | 추가: password: Option<&[u8]>, | |
| 75 | 추가: selected: Option<u32>, | |
| 76 | 추가: check: &mut impl crate::resources::Monitor, | |
| 56 | 77 | ) -> Result<Self> { |
| 57 | 78 | let mut magic = [0; 6]; |
| 58 | 79 | let n = len.min(6) as usize; |
| 59 | 80 | at(source, 0, &mut magic[..n])?; |
| 60 | 81 | if magic.starts_with(b"7z\xbc\xaf\x27\x1c") { |
| 61 | 삭제: return crate::seven_zip::open(source, len, limits, decode, check); | |
| 82 | 추가: return crate::seven_zip::open_selected(source, len, limits, decode, selected, check); | |
| 62 | 83 | } |
| 63 | 84 | if magic.starts_with(b"PK\x03\x04") |
| 64 | 85 | || magic.starts_with(b"PK\x05\x06") |
| 65 | 86 | || magic.starts_with(b"PK\x06\x06") |
| 66 | 87 | { |
| 67 | 삭제: return zip(source, len, limits, decode, password, check); | |
| 88 | 추가: return zip(source, len, limits, decode, password, selected, check); | |
| 68 | 89 | } |
| 69 | 90 | let compression = if magic.starts_with(b"BZh") { |
| 70 | 91 | Some(crate::compressed_tar::Compression::Bzip2) |
| @@ -425,6 +446,7 @@ fn zip( | ||
| 425 | 446 | limits: Limits, |
| 426 | 447 | decode: bool, |
| 427 | 448 | password: Option<&[u8]>, |
| 449 | 추가: selected: Option<u32>, | |
| 428 | 450 | check: &mut impl crate::resources::Monitor, |
| 429 | 451 | ) -> Result<Catalog> { |
| 430 | 452 | if len < 22 { |
| @@ -712,13 +734,22 @@ fn zip( | ||
| 712 | 734 | )?; |
| 713 | 735 | let mut data = spool::temporary()?; |
| 714 | 736 | if decode { |
| 715 | 삭제: crate::space::ensure(&data, total)?; | |
| 737 | 추가: let required = if let Some(id) = selected { | |
| 738 | 추가: members | |
| 739 | 추가: .get(id as usize) | |
| 740 | 추가: .ok_or(ErrorCode::InvalidRequest)? | |
| 741 | 추가: .entry | |
| 742 | 추가: .size | |
| 743 | 추가: } else { | |
| 744 | 추가: total | |
| 745 | 추가: }; | |
| 746 | 추가: crate::space::ensure(&data, required)?; | |
| 716 | 747 | } |
| 717 | 748 | let mut offsets = Vec::new(); |
| 718 | 749 | for (member, packed) in members.iter().zip(packed) { |
| 719 | 750 | check.check()?; |
| 720 | 751 | offsets.push(io(data.stream_position())?); |
| 721 | 삭제: if !decode { | |
| 752 | 추가: if !decode || selected.is_some_and(|id| id != member.entry.entry_id) { | |
| 722 | 753 | crate::resources::completed(Ok(()), check)?; |
| 723 | 754 | continue; |
| 724 | 755 | } |
| @@ -4656,11 +4656,14 @@ dependencies = [ | ||
| 4656 | 4656 | "hmac", |
| 4657 | 4657 | "lzma-rust2", |
| 4658 | 4658 | "pbkdf2", |
| 4659 | 추가: "png", | |
| 4659 | 4660 | "sha1", |
| 4660 | 4661 | "sha2 0.10.9", |
| 4661 | 4662 | "subtle", |
| 4662 | 4663 | "zeroize", |
| 4663 | 4664 | "zlib-rs", |
| 4665 | 추가: "zune-core", | |
| 4666 | 추가: "zune-jpeg", | |
| 4664 | 4667 | ] |
| 4665 | 4668 | |
| 4666 | 4669 | [[package]] |
| @@ -11,6 +11,13 @@ import tomllib | ||
| 11 | 11 | |
| 12 | 12 | ROOT = Path(__file__).resolve().parents[1] |
| 13 | 13 | |
| 14 | 추가: # 미리보기 디코더는 MIT 조건을 선택하며 원문 고지를 함께 수집함. | |
| 15 | 추가: LICENSE_CHOICES = { | |
| 16 | 추가: ("png", "0.18.1"): "MIT", | |
| 17 | 추가: ("zune-jpeg", "0.5.15"): "MIT", | |
| 18 | 추가: ("zune-core", "0.5.3"): "MIT", | |
| 19 | 추가: } | |
| 20 | 추가: | |
| 14 | 21 | |
| 15 | 22 | def identity(package): |
| 16 | 23 | return package["name"], package["version"], package.get("source") or "workspace" |
| @@ -186,6 +193,12 @@ def inventory(manifests, project_root=None, supplement_path=ROOT / "packaging/li | ||
| 186 | 193 | else: |
| 187 | 194 | records[key] = {"name": key[0], "version": key[1], "source": key[2], |
| 188 | 195 | "license": package["license"], "files": files} |
| 196 | 추가: for record in records.values(): | |
| 197 | 추가: selected = LICENSE_CHOICES.get((record["name"], record["version"])) | |
| 198 | 추가: if selected: | |
| 199 | 추가: if selected not in record["license"].split(" OR "): | |
| 200 | 추가: raise ValueError(f"선택한 라이선스 불일치: {record['name']}") | |
| 201 | 추가: record["selected_license"] = selected | |
| 189 | 202 | return [records[key] for key in sorted(records)] |
| 190 | 203 | |
| 191 | 204 | |
| @@ -231,6 +244,8 @@ def render(records): | ||
| 231 | 244 | for record in records: |
| 232 | 245 | lines.extend(["=" * 72, f'{record.get("kind", "Crate")}: {record["name"]} {record["version"]}', |
| 233 | 246 | f'Source: {record["source"]}', f'License: {record["license"]}', f'Version: {record["version"]}', ""]) |
| 247 | 추가: if record.get("selected_license"): | |
| 248 | 추가: lines.extend([f'Selected license: {record["selected_license"]}', ""]) | |
| 234 | 249 | for file in record["files"]: |
| 235 | 250 | lines.extend([f'File: {file["path"]}', f'SHA-256: {file["sha256"]}']) |
| 236 | 251 | if file.get("note"): |
| @@ -0,0 +1,32 @@ | ||
| 1 | 추가: """미리보기 디코더의 선택한 라이선스와 고지 원문을 검증함.""" | |
| 2 | 추가: import importlib.util | |
| 3 | 추가: from pathlib import Path | |
| 4 | 추가: import unittest | |
| 5 | 추가: | |
| 6 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 7 | 추가: SPEC = importlib.util.spec_from_file_location("preview_licenses", ROOT / "packaging/licenses.py") | |
| 8 | 추가: LICENSES = importlib.util.module_from_spec(SPEC) | |
| 9 | 추가: SPEC.loader.exec_module(LICENSES) | |
| 10 | 추가: | |
| 11 | 추가: | |
| 12 | 추가: class PreviewLicenses(unittest.TestCase): | |
| 13 | 추가: def test_decoder_notices_include_selected_mit_and_verified_originals(self): | |
| 14 | 추가: records = LICENSES.inventory([ROOT / "experiments/rust-archive-worker/Cargo.toml"]) | |
| 15 | 추가: selected = {record["name"]: record for record in records} | |
| 16 | 추가: for name, version in [("png", "0.18.1"), ("zune-jpeg", "0.5.15"), ("zune-core", "0.5.3")]: | |
| 17 | 추가: with self.subTest(name=name): | |
| 18 | 추가: record = selected[name] | |
| 19 | 추가: self.assertEqual(record["version"], version) | |
| 20 | 추가: self.assertEqual(record["selected_license"], "MIT") | |
| 21 | 추가: self.assertIn("MIT", record["license"].split(" OR ")) | |
| 22 | 추가: self.assertTrue(record["files"]) | |
| 23 | 추가: notice = LICENSES.render([record]) | |
| 24 | 추가: self.assertIn("Selected license: MIT", notice) | |
| 25 | 추가: for original in record["files"]: | |
| 26 | 추가: self.assertIn(original["text"], notice) | |
| 27 | 추가: self.assertIn(original["sha256"], notice) | |
| 28 | 추가: self.assertTrue({"libpng-sys", "libjpeg-sys", "mozjpeg-sys", "libz-sys"}.isdisjoint(selected)) | |
| 29 | 추가: | |
| 30 | 추가: | |
| 31 | 추가: if __name__ == "__main__": | |
| 32 | 추가: unittest.main() |
| @@ -2,6 +2,12 @@ | ||
| 2 | 2 | # It is not intended for manual editing. |
| 3 | 3 | version = 4 |
| 4 | 4 | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "adler2" | |
| 7 | 추가: version = "2.0.1" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" | |
| 10 | 추가: | |
| 5 | 11 | [[package]] |
| 6 | 12 | name = "aes" |
| 7 | 13 | version = "0.8.4" |
| @@ -14,6 +20,12 @@ dependencies = [ | ||
| 14 | 20 | "zeroize", |
| 15 | 21 | ] |
| 16 | 22 | |
| 23 | 추가: [[package]] | |
| 24 | 추가: name = "bitflags" | |
| 25 | 추가: version = "2.13.2" | |
| 26 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 27 | 추가: checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" | |
| 28 | 추가: | |
| 17 | 29 | [[package]] |
| 18 | 30 | name = "block-buffer" |
| 19 | 31 | version = "0.10.4" |
| @@ -81,6 +93,15 @@ dependencies = [ | ||
| 81 | 93 | "libc", |
| 82 | 94 | ] |
| 83 | 95 | |
| 96 | 추가: [[package]] | |
| 97 | 추가: name = "crc32fast" | |
| 98 | 추가: version = "1.5.5" | |
| 99 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 100 | 추가: checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" | |
| 101 | 추가: dependencies = [ | |
| 102 | 추가: "cfg-if", | |
| 103 | 추가: ] | |
| 104 | 추가: | |
| 84 | 105 | [[package]] |
| 85 | 106 | name = "crypto-common" |
| 86 | 107 | version = "0.1.7" |
| @@ -122,6 +143,26 @@ dependencies = [ | ||
| 122 | 143 | "crypto-common 0.2.2", |
| 123 | 144 | ] |
| 124 | 145 | |
| 146 | 추가: [[package]] | |
| 147 | 추가: name = "fdeflate" | |
| 148 | 추가: version = "0.3.7" | |
| 149 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 150 | 추가: checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" | |
| 151 | 추가: dependencies = [ | |
| 152 | 추가: "simd-adler32", | |
| 153 | 추가: ] | |
| 154 | 추가: | |
| 155 | 추가: [[package]] | |
| 156 | 추가: name = "flate2" | |
| 157 | 추가: version = "1.1.11" | |
| 158 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 159 | 추가: checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" | |
| 160 | 추가: dependencies = [ | |
| 161 | 추가: "crc32fast", | |
| 162 | 추가: "miniz_oxide 0.9.1", | |
| 163 | 추가: "zlib-rs", | |
| 164 | 추가: ] | |
| 165 | 추가: | |
| 125 | 166 | [[package]] |
| 126 | 167 | name = "generic-array" |
| 127 | 168 | version = "0.14.7" |
| @@ -180,6 +221,26 @@ dependencies = [ | ||
| 180 | 221 | "sha2 0.11.1", |
| 181 | 222 | ] |
| 182 | 223 | |
| 224 | 추가: [[package]] | |
| 225 | 추가: name = "miniz_oxide" | |
| 226 | 추가: version = "0.8.9" | |
| 227 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 228 | 추가: checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" | |
| 229 | 추가: dependencies = [ | |
| 230 | 추가: "adler2", | |
| 231 | 추가: "simd-adler32", | |
| 232 | 추가: ] | |
| 233 | 추가: | |
| 234 | 추가: [[package]] | |
| 235 | 추가: name = "miniz_oxide" | |
| 236 | 추가: version = "0.9.1" | |
| 237 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 238 | 추가: checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" | |
| 239 | 추가: dependencies = [ | |
| 240 | 추가: "adler2", | |
| 241 | 추가: "simd-adler32", | |
| 242 | 추가: ] | |
| 243 | 추가: | |
| 183 | 244 | [[package]] |
| 184 | 245 | name = "pbkdf2" |
| 185 | 246 | version = "0.12.2" |
| @@ -190,6 +251,19 @@ dependencies = [ | ||
| 190 | 251 | "hmac", |
| 191 | 252 | ] |
| 192 | 253 | |
| 254 | 추가: [[package]] | |
| 255 | 추가: name = "png" | |
| 256 | 추가: version = "0.18.1" | |
| 257 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 258 | 추가: checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" | |
| 259 | 추가: dependencies = [ | |
| 260 | 추가: "bitflags", | |
| 261 | 추가: "crc32fast", | |
| 262 | 추가: "fdeflate", | |
| 263 | 추가: "flate2", | |
| 264 | 추가: "miniz_oxide 0.8.9", | |
| 265 | 추가: ] | |
| 266 | 추가: | |
| 193 | 267 | [[package]] |
| 194 | 268 | name = "sha1" |
| 195 | 269 | version = "0.10.7" |
| @@ -223,6 +297,12 @@ dependencies = [ | ||
| 223 | 297 | "digest 0.11.3", |
| 224 | 298 | ] |
| 225 | 299 | |
| 300 | 추가: [[package]] | |
| 301 | 추가: name = "simd-adler32" | |
| 302 | 추가: version = "0.3.10" | |
| 303 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 304 | 추가: checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" | |
| 305 | 추가: | |
| 226 | 306 | [[package]] |
| 227 | 307 | name = "subtle" |
| 228 | 308 | version = "2.6.1" |
| @@ -256,11 +336,14 @@ dependencies = [ | ||
| 256 | 336 | "hmac", |
| 257 | 337 | "lzma-rust2", |
| 258 | 338 | "pbkdf2", |
| 339 | 추가: "png", | |
| 259 | 340 | "sha1", |
| 260 | 341 | "sha2 0.10.9", |
| 261 | 342 | "subtle", |
| 262 | 343 | "zeroize", |
| 263 | 344 | "zlib-rs", |
| 345 | 추가: "zune-core", | |
| 346 | 추가: "zune-jpeg", | |
| 264 | 347 | ] |
| 265 | 348 | |
| 266 | 349 | [[package]] |
| @@ -275,3 +358,18 @@ name = "zlib-rs" | ||
| 275 | 358 | version = "0.6.8" |
| 276 | 359 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 277 | 360 | checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| 361 | 추가: | |
| 362 | 추가: [[package]] | |
| 363 | 추가: name = "zune-core" | |
| 364 | 추가: version = "0.5.3" | |
| 365 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 366 | 추가: checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" | |
| 367 | 추가: | |
| 368 | 추가: [[package]] | |
| 369 | 추가: name = "zune-jpeg" | |
| 370 | 추가: version = "0.5.15" | |
| 371 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 372 | 추가: checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" | |
| 373 | 추가: dependencies = [ | |
| 374 | 추가: "zune-core", | |
| 375 | 추가: ] |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기| @@ -8,7 +8,7 @@ impl Drop for Running { | ||
| 8 | 8 | let _ = self.0.wait(); |
| 9 | 9 | } |
| 10 | 10 | } |
| 11 | 삭제: fn run( | |
| 11 | 추가: pub(super) fn run( | |
| 12 | 12 | s: &Scratch, |
| 13 | 13 | start: GuardedStart, |
| 14 | 14 | respond: impl FnMut(&Message) -> Option<Vec<Message>>, |
| @@ -1614,6 +1614,8 @@ mod conflict_wire; | ||
| 1614 | 1614 | |
| 1615 | 1615 | mod preview_wire; |
| 1616 | 1616 | |
| 1617 | 추가: mod preview_runtime; | |
| 1618 | 추가: | |
| 1617 | 1619 | mod conflicts; |
| 1618 | 1620 | |
| 1619 | 1621 | mod compressed_tar; |
| @@ -0,0 +1,64 @@ | ||
| 1 | 추가: """독립 압축기로 미리보기 입력을 생성함.""" | |
| 2 | 추가: import gzip | |
| 3 | 추가: import io | |
| 4 | 추가: from pathlib import Path | |
| 5 | 추가: import sys | |
| 6 | 추가: import struct | |
| 7 | 추가: import zlib | |
| 8 | 추가: import tarfile | |
| 9 | 추가: import zipfile | |
| 10 | 추가: | |
| 11 | 추가: from seven_zip_fixtures import archive, integer, property_bytes, SIGNATURE | |
| 12 | 추가: | |
| 13 | 추가: root = Path(sys.argv[1]) | |
| 14 | 추가: kind = sys.argv[2] | |
| 15 | 추가: name = sys.argv[3] | |
| 16 | 추가: data = (root / "payload").read_bytes() | |
| 17 | 추가: if kind.startswith("zip"): | |
| 18 | 추가: with zipfile.ZipFile(root / "input", "w", compression=zipfile.ZIP_DEFLATED) as target: | |
| 19 | 추가: if kind.startswith("zip-selected"): | |
| 20 | 추가: target.writestr("before.bin", b"unselected" * 10000) | |
| 21 | 추가: target.writestr(name, data) | |
| 22 | 추가: target.writestr("after.bin", b"unselected" * 10000) | |
| 23 | 추가: if kind == "zip-selected-damaged": | |
| 24 | 추가: with zipfile.ZipFile(root / "input") as target: | |
| 25 | 추가: info = target.getinfo("before.bin") | |
| 26 | 추가: raw = bytearray((root / "input").read_bytes()) | |
| 27 | 추가: name_size, extra_size = struct.unpack_from("<HH", raw, info.header_offset + 26) | |
| 28 | 추가: at = info.header_offset + 30 + name_size + extra_size + info.compress_size // 2 | |
| 29 | 추가: raw[at] ^= 1 | |
| 30 | 추가: (root / "input").write_bytes(raw) | |
| 31 | 추가: elif kind == "7z-folders": | |
| 32 | 추가: entries = [("before.bin", b"prefix" * 10000), (name, data), ("after.bin", b"suffix" * 10000)] | |
| 33 | 추가: parts = [part for _, part in entries] | |
| 34 | 추가: info = b"\x06\x00\x03\x09" + b"".join(integer(len(part)) for part in parts) + b"\x00" | |
| 35 | 추가: info += b"\x07\x0b\x03\x00" + b"\x01\x01\x00" * 3 + b"\x0c" | |
| 36 | 추가: info += b"".join(integer(len(part)) for part in parts) | |
| 37 | 추가: info += b"\x0a\x01" + b"".join(struct.pack("<I", zlib.crc32(part)) for part in parts) + b"\x00\x08\x00\x00" | |
| 38 | 추가: files = b"\x05\x03" + property_bytes(17, b"\x00" + b"".join(n.encode("utf-16le") + b"\x00\x00" for n, _ in entries)) | |
| 39 | 추가: header = b"\x01\x04" + info + files + b"\x00\x00" | |
| 40 | 추가: content = b"".join(parts) | |
| 41 | 추가: start = struct.pack("<QQI", len(content), len(header), zlib.crc32(header)) | |
| 42 | 추가: (root / "input").write_bytes(SIGNATURE + struct.pack("<I", zlib.crc32(start)) + start + content + header) | |
| 43 | 추가: elif kind == "aes": | |
| 44 | 추가: import encryption_fixtures | |
| 45 | 추가: encryption_fixtures.PAYLOAD = data | |
| 46 | 추가: raw = encryption_fixtures.aes_zip(2, 8) | |
| 47 | 추가: assert raw.count(b"payload.bin") == 2 | |
| 48 | 추가: (root / "input").write_bytes(raw.replace(b"payload.bin", b"payload.txt")) | |
| 49 | 추가: elif kind.startswith("7z"): | |
| 50 | 추가: entries = [("before.bin", b"solid prefix" * 20000, 0x20), (name, data, 0x20), ("after.bin", b"solid suffix" * 10000, 0x20)] | |
| 51 | 추가: (root / "input").write_bytes(archive(entries, method=kind.split("-")[1], encoded=True)) | |
| 52 | 추가: elif kind == "gzip": | |
| 53 | 추가: (root / (name + ".gz")).write_bytes(gzip.compress(data, mtime=0)) | |
| 54 | 추가: else: | |
| 55 | 추가: with tarfile.open(root / "input", "w" if kind.startswith("tar") else "w:" + kind, format=tarfile.USTAR_FORMAT) as target: | |
| 56 | 추가: info = tarfile.TarInfo(name) | |
| 57 | 추가: info.size = len(data) | |
| 58 | 추가: if kind in {"tar-folder", "tar-link"}: | |
| 59 | 추가: info.type = tarfile.DIRTYPE if kind == "tar-folder" else tarfile.SYMTYPE | |
| 60 | 추가: info.linkname = "target.txt" if kind == "tar-link" else "" | |
| 61 | 추가: info.size = 0 | |
| 62 | 추가: target.addfile(info) | |
| 63 | 추가: else: | |
| 64 | 추가: target.addfile(info, io.BytesIO(data)) |
| @@ -0,0 +1,280 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: | |
| 3 | 추가: fn png_bytes( | |
| 4 | 추가: width: u32, | |
| 5 | 추가: height: u32, | |
| 6 | 추가: color: png::ColorType, | |
| 7 | 추가: depth: png::BitDepth, | |
| 8 | 추가: data: &[u8], | |
| 9 | 추가: ) -> Vec<u8> { | |
| 10 | 추가: let mut bytes = Vec::new(); | |
| 11 | 추가: let mut encoder = png::Encoder::new(&mut bytes, width, height); | |
| 12 | 추가: encoder.set_color(color); | |
| 13 | 추가: encoder.set_depth(depth); | |
| 14 | 추가: encoder | |
| 15 | 추가: .write_header() | |
| 16 | 추가: .unwrap() | |
| 17 | 추가: .write_image_data(data) | |
| 18 | 추가: .unwrap(); | |
| 19 | 추가: bytes | |
| 20 | 추가: } | |
| 21 | 추가: fn pixel() -> Vec<u8> { | |
| 22 | 추가: png_bytes( | |
| 23 | 추가: 1, | |
| 24 | 추가: 1, | |
| 25 | 추가: png::ColorType::Rgba, | |
| 26 | 추가: png::BitDepth::Eight, | |
| 27 | 추가: &[10, 20, 30, 40], | |
| 28 | 추가: ) | |
| 29 | 추가: } | |
| 30 | 추가: fn chunk(kind: &[u8; 4], bytes: &[u8]) -> Vec<u8> { | |
| 31 | 추가: let mut result = (bytes.len() as u32).to_be_bytes().to_vec(); | |
| 32 | 추가: result.extend(kind); | |
| 33 | 추가: result.extend(bytes); | |
| 34 | 추가: result.extend(crc32(0, &result[4..]).to_be_bytes()); | |
| 35 | 추가: result | |
| 36 | 추가: } | |
| 37 | 추가: fn run(kind: Kind, bytes: Vec<u8>) -> Result<(PreviewInfo, Vec<u8>)> { | |
| 38 | 추가: decode(kind, 7, bytes, &mut || Ok(())) | |
| 39 | 추가: } | |
| 40 | 추가: | |
| 41 | 추가: #[test] | |
| 42 | 추가: fn preview_text_checks_utf8_bom_and_source_boundaries() { | |
| 43 | 추가: for bytes in [ | |
| 44 | 추가: Vec::new(), | |
| 45 | 추가: vec![b'x'; MAX_PREVIEW_TEXT_BYTES as usize], | |
| 46 | 추가: "한글\n".as_bytes().to_vec(), | |
| 47 | 추가: vec![0xef, 0xbb, 0xbf], | |
| 48 | 추가: ] { | |
| 49 | 추가: let (info, data) = run(Kind::Text, bytes.clone()).unwrap(); | |
| 50 | 추가: assert!(info.valid()); | |
| 51 | 추가: assert_eq!(info.entry_id, 7); | |
| 52 | 추가: assert_eq!(info.total_bytes, data.len() as u64); | |
| 53 | 추가: assert_eq!(info.format, PreviewFormat::Utf8Text); | |
| 54 | 추가: assert_eq!( | |
| 55 | 추가: data, | |
| 56 | 추가: bytes.strip_prefix(&[0xef, 0xbb, 0xbf]).unwrap_or(&bytes) | |
| 57 | 추가: ); | |
| 58 | 추가: } | |
| 59 | 추가: assert!(matches!( | |
| 60 | 추가: run(Kind::Text, vec![b'x'; MAX_PREVIEW_TEXT_BYTES as usize + 1]), | |
| 61 | 추가: Err(ErrorCode::Limit) | |
| 62 | 추가: )); | |
| 63 | 추가: assert!(matches!( | |
| 64 | 추가: run(Kind::Text, vec![0xff]), | |
| 65 | 추가: Err(ErrorCode::Integrity) | |
| 66 | 추가: )); | |
| 67 | 추가: assert!(matches!( | |
| 68 | 추가: run(Kind::Text, vec![0xef, 0xbb, 0xbf, 0xff]), | |
| 69 | 추가: Err(ErrorCode::Integrity) | |
| 70 | 추가: )); | |
| 71 | 추가: } | |
| 72 | 추가: #[test] | |
| 73 | 추가: fn preview_extensions_are_explicit_and_ascii_case_insensitive() { | |
| 74 | 추가: for name in [ | |
| 75 | 추가: "a.txt", "a.MD", "a.log", "a.csv", "a.JSON", "a.PnG", "a.jpg", "a.JPEG", | |
| 76 | 추가: ] { | |
| 77 | 추가: assert!(Kind::from_name(name).is_ok()); | |
| 78 | 추가: } | |
| 79 | 추가: for name in ["a.svg", "a.gif", "a.webp", "a.exe", "a", "folder.txt/child"] { | |
| 80 | 추가: assert!(Kind::from_name(name).is_err()); | |
| 81 | 추가: } | |
| 82 | 추가: } | |
| 83 | 추가: #[test] | |
| 84 | 추가: fn preview_png_normalizes_gray_rgb_alpha_and_sixteen_bit_pixels() { | |
| 85 | 추가: for (color, depth, source, expected) in [ | |
| 86 | 추가: ( | |
| 87 | 추가: png::ColorType::Rgba, | |
| 88 | 추가: png::BitDepth::Eight, | |
| 89 | 추가: vec![10, 20, 30, 40], | |
| 90 | 추가: vec![10, 20, 30, 40], | |
| 91 | 추가: ), | |
| 92 | 추가: ( | |
| 93 | 추가: png::ColorType::Rgb, | |
| 94 | 추가: png::BitDepth::Eight, | |
| 95 | 추가: vec![10, 20, 30], | |
| 96 | 추가: vec![10, 20, 30, 255], | |
| 97 | 추가: ), | |
| 98 | 추가: ( | |
| 99 | 추가: png::ColorType::Grayscale, | |
| 100 | 추가: png::BitDepth::Eight, | |
| 101 | 추가: vec![10], | |
| 102 | 추가: vec![10, 10, 10, 255], | |
| 103 | 추가: ), | |
| 104 | 추가: ( | |
| 105 | 추가: png::ColorType::GrayscaleAlpha, | |
| 106 | 추가: png::BitDepth::Eight, | |
| 107 | 추가: vec![10, 40], | |
| 108 | 추가: vec![10, 10, 10, 40], | |
| 109 | 추가: ), | |
| 110 | 추가: ( | |
| 111 | 추가: png::ColorType::GrayscaleAlpha, | |
| 112 | 추가: png::BitDepth::Sixteen, | |
| 113 | 추가: vec![10, 99, 40, 99], | |
| 114 | 추가: vec![10, 10, 10, 40], | |
| 115 | 추가: ), | |
| 116 | 추가: ] { | |
| 117 | 추가: let (info, data) = run(Kind::Png, png_bytes(1, 1, color, depth, &source)).unwrap(); | |
| 118 | 추가: assert_eq!((info.width, info.height, info.total_bytes), (1, 1, 4)); | |
| 119 | 추가: assert_eq!(data, expected); | |
| 120 | 추가: } | |
| 121 | 추가: } | |
| 122 | 추가: #[test] | |
| 123 | 추가: fn preview_png_rejects_crc_truncation_animation_and_format_mismatch() { | |
| 124 | 추가: let original = pixel(); | |
| 125 | 추가: for length in [8, original.len() - 12, original.len() - 1] { | |
| 126 | 추가: assert!(run(Kind::Png, original[..length].to_vec()).is_err()); | |
| 127 | 추가: } | |
| 128 | 추가: let mut bad = original.clone(); | |
| 129 | 추가: bad[29] ^= 1; | |
| 130 | 추가: assert!(matches!(run(Kind::Png, bad), Err(ErrorCode::Integrity))); | |
| 131 | 추가: let mut trailing = original.clone(); | |
| 132 | 추가: trailing.push(0); | |
| 133 | 추가: assert!(matches!( | |
| 134 | 추가: run(Kind::Png, trailing), | |
| 135 | 추가: Err(ErrorCode::Integrity) | |
| 136 | 추가: )); | |
| 137 | 추가: let mut animated = original.clone(); | |
| 138 | 추가: animated.splice(33..33, chunk(b"acTL", &[0, 0, 0, 1, 0, 0, 0, 0])); | |
| 139 | 추가: assert!(matches!( | |
| 140 | 추가: run(Kind::Png, animated), | |
| 141 | 추가: Err(ErrorCode::UnsupportedFeature) | |
| 142 | 추가: )); | |
| 143 | 추가: assert!(matches!( | |
| 144 | 추가: run(Kind::Png, b"GIF89a".to_vec()), | |
| 145 | 추가: Err(ErrorCode::UnsupportedFormat) | |
| 146 | 추가: )); | |
| 147 | 추가: } | |
| 148 | 추가: #[test] | |
| 149 | 추가: fn preview_png_checks_dimensions_and_pixels_before_decoding() { | |
| 150 | 추가: for (width, height) in [ | |
| 151 | 추가: (8193u32, 1u32), | |
| 152 | 추가: (1, 8193), | |
| 153 | 추가: (4001, 4000), | |
| 154 | 추가: (8192, 8192), | |
| 155 | 추가: (u32::MAX, u32::MAX), | |
| 156 | 추가: ] { | |
| 157 | 추가: let mut bytes = pixel(); | |
| 158 | 추가: bytes[16..20].copy_from_slice(&width.to_be_bytes()); | |
| 159 | 추가: bytes[20..24].copy_from_slice(&height.to_be_bytes()); | |
| 160 | 추가: let crc = crc32(0, &bytes[12..29]); | |
| 161 | 추가: bytes[29..33].copy_from_slice(&crc.to_be_bytes()); | |
| 162 | 추가: assert!( | |
| 163 | 추가: matches!(run(Kind::Png, bytes), Err(ErrorCode::Limit)), | |
| 164 | 추가: "{width}x{height}" | |
| 165 | 추가: ); | |
| 166 | 추가: } | |
| 167 | 추가: for (width, height) in [(8192, 1), (1, 8192), (4000, 4000)] { | |
| 168 | 추가: let bytes = png_bytes( | |
| 169 | 추가: width, | |
| 170 | 추가: height, | |
| 171 | 추가: png::ColorType::Rgba, | |
| 172 | 추가: png::BitDepth::Eight, | |
| 173 | 추가: &vec![0; (width * height * 4) as usize], | |
| 174 | 추가: ); | |
| 175 | 추가: let (info, rgba) = run(Kind::Png, bytes).unwrap(); | |
| 176 | 추가: assert_eq!((info.width, info.height), (width, height)); | |
| 177 | 추가: assert_eq!(rgba.len(), (width * height * 4) as usize); | |
| 178 | 추가: } | |
| 179 | 추가: } | |
| 180 | 추가: #[test] | |
| 181 | 추가: fn preview_image_source_limit_includes_ancillary_bytes() { | |
| 182 | 추가: let mut bytes = pixel(); | |
| 183 | 추가: let at = bytes.len() - 12; | |
| 184 | 추가: let padding = vec![0; MAX_PREVIEW_IMAGE_BYTES as usize - bytes.len() - 12]; | |
| 185 | 추가: bytes.splice(at..at, chunk(b"teSt", &padding)); | |
| 186 | 추가: assert_eq!(bytes.len(), MAX_PREVIEW_IMAGE_BYTES as usize); | |
| 187 | 추가: assert!(run(Kind::Png, bytes.clone()).is_ok()); | |
| 188 | 추가: bytes.push(0); | |
| 189 | 추가: assert!(matches!(run(Kind::Png, bytes), Err(ErrorCode::Limit))); | |
| 190 | 추가: assert!(matches!( | |
| 191 | 추가: run(Kind::Jpeg, vec![0; MAX_PREVIEW_IMAGE_BYTES as usize + 1]), | |
| 192 | 추가: Err(ErrorCode::Limit) | |
| 193 | 추가: )); | |
| 194 | 추가: } | |
| 195 | 추가: #[test] | |
| 196 | 추가: fn preview_jpeg_strictly_decodes_baseline_and_progressive() { | |
| 197 | 추가: for bytes in [ | |
| 198 | 추가: include_bytes!("fixtures/preview-baseline.jpg").as_slice(), | |
| 199 | 추가: include_bytes!("fixtures/preview-progressive.jpg").as_slice(), | |
| 200 | 추가: ] { | |
| 201 | 추가: let (info, data) = run(Kind::Jpeg, bytes.to_vec()).unwrap(); | |
| 202 | 추가: assert_eq!((info.width, info.height, info.total_bytes), (3, 2, 24)); | |
| 203 | 추가: for pixel in data.chunks_exact(4) { | |
| 204 | 추가: assert_eq!(pixel[3], 255); | |
| 205 | 추가: assert!(pixel[0] > 200 && pixel[1] < 60 && pixel[2] < 80); | |
| 206 | 추가: } | |
| 207 | 추가: for length in [2, bytes.len() / 2, bytes.len() - 1] { | |
| 208 | 추가: assert!(run(Kind::Jpeg, bytes[..length].to_vec()).is_err()); | |
| 209 | 추가: } | |
| 210 | 추가: let mut incomplete = bytes[..bytes.len() / 2].to_vec(); | |
| 211 | 추가: incomplete.extend([0xff, 0xd9]); | |
| 212 | 추가: assert!(run(Kind::Jpeg, incomplete).is_err()); | |
| 213 | 추가: } | |
| 214 | 추가: assert!(matches!( | |
| 215 | 추가: run(Kind::Jpeg, pixel()), | |
| 216 | 추가: Err(ErrorCode::UnsupportedFormat) | |
| 217 | 추가: )); | |
| 218 | 추가: } | |
| 219 | 추가: #[test] | |
| 220 | 추가: fn preview_cancellation_discards_decoded_results_and_conversion() { | |
| 221 | 추가: for kind in [Kind::Text, Kind::Png, Kind::Jpeg] { | |
| 222 | 추가: let source = match kind { | |
| 223 | 추가: Kind::Text => b"text".to_vec(), | |
| 224 | 추가: Kind::Png => pixel(), | |
| 225 | 추가: Kind::Jpeg => include_bytes!("fixtures/preview-baseline.jpg").to_vec(), | |
| 226 | 추가: }; | |
| 227 | 추가: let mut calls = 0; | |
| 228 | 추가: assert!(matches!( | |
| 229 | 추가: decode(kind, 7, source, &mut || { | |
| 230 | 추가: calls += 1; | |
| 231 | 추가: if calls >= 2 { | |
| 232 | 추가: Err(ErrorCode::None) | |
| 233 | 추가: } else { | |
| 234 | 추가: Ok(()) | |
| 235 | 추가: } | |
| 236 | 추가: }), | |
| 237 | 추가: Err(ErrorCode::None) | |
| 238 | 추가: )); | |
| 239 | 추가: } | |
| 240 | 추가: } | |
| 241 | 추가: | |
| 242 | 추가: #[test] | |
| 243 | 추가: fn preview_jpeg_checks_dimensions_before_decoder_allocation() { | |
| 244 | 추가: let original = include_bytes!("fixtures/preview-baseline.jpg"); | |
| 245 | 추가: let at = original.windows(2).position(|p| p == [0xff, 0xc0]).unwrap(); | |
| 246 | 추가: for (width, height) in [(8193u16, 1u16), (1, 8193), (4001, 4000), (8192, 8192)] { | |
| 247 | 추가: let mut bytes = original.to_vec(); | |
| 248 | 추가: bytes[at + 5..at + 7].copy_from_slice(&height.to_be_bytes()); | |
| 249 | 추가: bytes[at + 7..at + 9].copy_from_slice(&width.to_be_bytes()); | |
| 250 | 추가: assert!( | |
| 251 | 추가: matches!(run(Kind::Jpeg, bytes), Err(ErrorCode::Limit)), | |
| 252 | 추가: "{width}x{height}" | |
| 253 | 추가: ); | |
| 254 | 추가: } | |
| 255 | 추가: let mut multiple = original.to_vec(); | |
| 256 | 추가: multiple.extend(original); | |
| 257 | 추가: assert!(run(Kind::Jpeg, multiple).is_err()); | |
| 258 | 추가: } | |
| 259 | 추가: | |
| 260 | 추가: #[test] | |
| 261 | 추가: fn preview_jpeg_normalizes_gray_and_cmyk_to_rgba() { | |
| 262 | 추가: for (bytes, gray) in [ | |
| 263 | 추가: (include_bytes!("fixtures/preview-gray.jpg").as_slice(), true), | |
| 264 | 추가: ( | |
| 265 | 추가: include_bytes!("fixtures/preview-cmyk.jpg").as_slice(), | |
| 266 | 추가: false, | |
| 267 | 추가: ), | |
| 268 | 추가: ] { | |
| 269 | 추가: let (info, pixels) = run(Kind::Jpeg, bytes.to_vec()).unwrap(); | |
| 270 | 추가: assert_eq!((info.width, info.height, info.total_bytes), (3, 2, 24)); | |
| 271 | 추가: for pixel in pixels.chunks_exact(4) { | |
| 272 | 추가: assert_eq!(pixel[3], 255); | |
| 273 | 추가: if gray { | |
| 274 | 추가: assert!(pixel[..3].iter().all(|v| v.abs_diff(80) <= 2)); | |
| 275 | 추가: } else { | |
| 276 | 추가: assert!(pixel[0] > 240 && pixel[1] < 20 && pixel[2] < 20); | |
| 277 | 추가: } | |
| 278 | 추가: } | |
| 279 | 추가: } | |
| 280 | 추가: } |
| @@ -0,0 +1,383 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: use sha2::{Digest, Sha256}; | |
| 3 | 추가: | |
| 4 | 추가: fn fixture(format: &str, name: &str, bytes: &[u8]) -> (Scratch, String, ListId, u32) { | |
| 5 | 추가: let s = Scratch::new(); | |
| 6 | 추가: fs::write(s.0.join("payload"), bytes).unwrap(); | |
| 7 | 추가: let script = PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 8 | 추가: .join("../../tests/rust-archive-worker/preview_cases.py"); | |
| 9 | 추가: let result = Command::new("python3") | |
| 10 | 추가: .arg("-B") | |
| 11 | 추가: .arg(script) | |
| 12 | 추가: .arg(&s.0) | |
| 13 | 추가: .arg(format) | |
| 14 | 추가: .arg(name) | |
| 15 | 추가: .output() | |
| 16 | 추가: .unwrap(); | |
| 17 | 추가: assert!( | |
| 18 | 추가: result.status.success(), | |
| 19 | 추가: "{}", | |
| 20 | 추가: String::from_utf8_lossy(&result.stderr) | |
| 21 | 추가: ); | |
| 22 | 추가: let path = if format == "gzip" { | |
| 23 | 추가: format!("{name}.gz") | |
| 24 | 추가: } else { | |
| 25 | 추가: "input".into() | |
| 26 | 추가: }; | |
| 27 | 추가: let events = execute(Start { | |
| 28 | 추가: action: Action::List { | |
| 29 | 추가: archive: s.path(&path), | |
| 30 | 추가: }, | |
| 31 | 추가: limits: Limits::default(), | |
| 32 | 추가: }); | |
| 33 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}"); | |
| 34 | 추가: let id = events | |
| 35 | 추가: .iter() | |
| 36 | 추가: .find_map(|e| match e { | |
| 37 | 추가: Message::Entry(entry) if entry.name == name || format == "gzip" => Some(entry.entry_id), | |
| 38 | 추가: _ => None, | |
| 39 | 추가: }) | |
| 40 | 추가: .unwrap(); | |
| 41 | 추가: let list = events | |
| 42 | 추가: .into_iter() | |
| 43 | 추가: .find_map(|e| match e { | |
| 44 | 추가: Message::ListEnd { list_id, .. } => Some(list_id), | |
| 45 | 추가: _ => None, | |
| 46 | 추가: }) | |
| 47 | 추가: .unwrap(); | |
| 48 | 추가: (s, path, list, id) | |
| 49 | 추가: } | |
| 50 | 추가: fn request(s: &Scratch, path: &str, list_id: ListId, entry_id: u32) -> GuardedStart { | |
| 51 | 추가: GuardedStart { | |
| 52 | 추가: start: Start { | |
| 53 | 추가: action: Action::Preview { | |
| 54 | 추가: archive: s.path(path), | |
| 55 | 추가: entry_id, | |
| 56 | 추가: list_id, | |
| 57 | 추가: }, | |
| 58 | 추가: limits: Limits::default(), | |
| 59 | 추가: }, | |
| 60 | 추가: ceiling: Limits::default(), | |
| 61 | 추가: interactive: true, | |
| 62 | 추가: } | |
| 63 | 추가: } | |
| 64 | 추가: fn run(s: &Scratch, start: GuardedStart) -> Vec<Message> { | |
| 65 | 추가: guarded::run(s, start, |event| match event { | |
| 66 | 추가: Message::ResourceRequired { | |
| 67 | 추가: challenge_id, | |
| 68 | 추가: scope, | |
| 69 | 추가: .. | |
| 70 | 추가: } => Some(vec![Message::ResourceReply { | |
| 71 | 추가: challenge_id: *challenge_id, | |
| 72 | 추가: scope: *scope, | |
| 73 | 추가: allow: true, | |
| 74 | 추가: }]), | |
| 75 | 추가: Message::PasswordRequired { challenge_id, .. } => Some(vec![Message::Password { | |
| 76 | 추가: challenge_id: *challenge_id, | |
| 77 | 추가: secret: Secret(b"fixture-password".to_vec()), | |
| 78 | 추가: }]), | |
| 79 | 추가: _ => None, | |
| 80 | 추가: }) | |
| 81 | 추가: } | |
| 82 | 추가: fn result(events: &[Message]) -> (PreviewInfo, Vec<u8>) { | |
| 83 | 추가: let terminal = terminal(events); | |
| 84 | 추가: assert_eq!(terminal.outcome, Outcome::Completed, "{events:?}"); | |
| 85 | 추가: assert_eq!(terminal.publication, Publication::None); | |
| 86 | 추가: assert_eq!(terminal.created_count, 0); | |
| 87 | 추가: assert_eq!(terminal.cleanup, Cleanup::Complete); | |
| 88 | 추가: assert!( | |
| 89 | 추가: !events | |
| 90 | 추가: .iter() | |
| 91 | 추가: .any(|e| matches!(e, Message::Output { .. } | Message::ConflictRequired { .. })) | |
| 92 | 추가: ); | |
| 93 | 추가: let mut info = None; | |
| 94 | 추가: let mut data = Vec::new(); | |
| 95 | 추가: let mut ended = false; | |
| 96 | 추가: for event in events { | |
| 97 | 추가: match event { | |
| 98 | 추가: Message::PreviewBegin(value) => { | |
| 99 | 추가: assert!(info.replace(*value).is_none()); | |
| 100 | 추가: assert!(value.valid()); | |
| 101 | 추가: } | |
| 102 | 추가: Message::PreviewChunk { | |
| 103 | 추가: entry_id, | |
| 104 | 추가: offset, | |
| 105 | 추가: data: bytes, | |
| 106 | 추가: } => { | |
| 107 | 추가: assert!(!ended); | |
| 108 | 추가: assert_eq!(Some(*entry_id), info.map(|i| i.entry_id)); | |
| 109 | 추가: assert_eq!(*offset, data.len() as u64); | |
| 110 | 추가: assert!(bytes.len() <= MAX_PREVIEW_CHUNK_BYTES); | |
| 111 | 추가: data.extend(bytes); | |
| 112 | 추가: } | |
| 113 | 추가: Message::PreviewEnd { | |
| 114 | 추가: entry_id, | |
| 115 | 추가: total_bytes, | |
| 116 | 추가: sha256, | |
| 117 | 추가: } => { | |
| 118 | 추가: assert!(!ended); | |
| 119 | 추가: ended = true; | |
| 120 | 추가: let info = info.unwrap(); | |
| 121 | 추가: assert_eq!(*entry_id, info.entry_id); | |
| 122 | 추가: assert_eq!(*total_bytes, info.total_bytes); | |
| 123 | 추가: assert_eq!(*total_bytes, data.len() as u64); | |
| 124 | 추가: assert_eq!(*sha256, <[u8; 32]>::from(Sha256::digest(&data))); | |
| 125 | 추가: } | |
| 126 | 추가: _ => {} | |
| 127 | 추가: } | |
| 128 | 추가: } | |
| 129 | 추가: assert!(ended); | |
| 130 | 추가: (info.unwrap(), data) | |
| 131 | 추가: } | |
| 132 | 추가: fn no_result(events: &[Message], error: ErrorCode) { | |
| 133 | 추가: assert_eq!(terminal(events).outcome, Outcome::Failed, "{events:?}"); | |
| 134 | 추가: assert_eq!(terminal(events).error, error, "{events:?}"); | |
| 135 | 추가: assert_eq!(terminal(events).publication, Publication::None); | |
| 136 | 추가: assert_eq!(terminal(events).created_count, 0); | |
| 137 | 추가: assert!(!events.iter().any(|e| matches!( | |
| 138 | 추가: e, | |
| 139 | 추가: Message::PreviewBegin(_) | |
| 140 | 추가: | Message::PreviewChunk { .. } | |
| 141 | 추가: | Message::PreviewEnd { .. } | |
| 142 | 추가: | Message::Output { .. } | |
| 143 | 추가: ))); | |
| 144 | 추가: } | |
| 145 | 추가: fn png(width: u32, height: u32) -> Vec<u8> { | |
| 146 | 추가: let mut bytes = Vec::new(); | |
| 147 | 추가: let mut encoder = png::Encoder::new(&mut bytes, width, height); | |
| 148 | 추가: encoder.set_color(png::ColorType::Rgba); | |
| 149 | 추가: let mut writer = encoder.write_header().unwrap(); | |
| 150 | 추가: writer | |
| 151 | 추가: .write_image_data(&vec![20; (width * height * 4) as usize]) | |
| 152 | 추가: .unwrap(); | |
| 153 | 추가: drop(writer); | |
| 154 | 추가: bytes | |
| 155 | 추가: } | |
| 156 | 추가: #[test] | |
| 157 | 추가: fn preview_actual_formats_keep_source_and_publish_nothing() { | |
| 158 | 추가: for format in [ | |
| 159 | 추가: "zip", | |
| 160 | 추가: "zip-selected", | |
| 161 | 추가: "zip-selected-damaged", | |
| 162 | 추가: "7z-folders", | |
| 163 | 추가: "tar", | |
| 164 | 추가: "gz", | |
| 165 | 추가: "bz2", | |
| 166 | 추가: "xz", | |
| 167 | 추가: "gzip", | |
| 168 | 추가: "7z-copy", | |
| 169 | 추가: "7z-lzma", | |
| 170 | 추가: "7z-lzma2", | |
| 171 | 추가: "aes", | |
| 172 | 추가: ] { | |
| 173 | 추가: let expected = "가나다\n".repeat(10000); | |
| 174 | 추가: let (s, path, list, id) = fixture(format, "payload.txt", expected.as_bytes()); | |
| 175 | 추가: let original = fs::read(s.0.join(&path)).unwrap(); | |
| 176 | 추가: let (_, data) = result(&run(&s, request(&s, &path, list, id))); | |
| 177 | 추가: assert_eq!(data, expected.as_bytes(), "{format}"); | |
| 178 | 추가: assert_eq!(fs::read(s.0.join(&path)).unwrap(), original); | |
| 179 | 추가: assert_eq!(fs::read_dir(&s.0).unwrap().count(), 2); | |
| 180 | 추가: } | |
| 181 | 추가: } | |
| 182 | 추가: #[test] | |
| 183 | 추가: fn preview_actual_png_and_jpeg_have_exact_rgba_metadata() { | |
| 184 | 추가: for (name, bytes, width, height) in [ | |
| 185 | 추가: ("payload.png", png(3, 2), 3, 2), | |
| 186 | 추가: ( | |
| 187 | 추가: "payload.jpg", | |
| 188 | 추가: include_bytes!("fixtures/preview-baseline.jpg").to_vec(), | |
| 189 | 추가: 3, | |
| 190 | 추가: 2, | |
| 191 | 추가: ), | |
| 192 | 추가: ( | |
| 193 | 추가: "payload.jpeg", | |
| 194 | 추가: include_bytes!("fixtures/preview-progressive.jpg").to_vec(), | |
| 195 | 추가: 3, | |
| 196 | 추가: 2, | |
| 197 | 추가: ), | |
| 198 | 추가: ] { | |
| 199 | 추가: for format in ["zip", "tar", "7z-lzma2"] { | |
| 200 | 추가: let (s, path, list, id) = fixture(format, name, &bytes); | |
| 201 | 추가: let (info, data) = result(&run(&s, request(&s, &path, list, id))); | |
| 202 | 추가: assert_eq!( | |
| 203 | 추가: (info.width, info.height, info.total_bytes), | |
| 204 | 추가: (width, height, u64::from(width * height * 4)) | |
| 205 | 추가: ); | |
| 206 | 추가: assert_eq!(data.len(), (width * height * 4) as usize); | |
| 207 | 추가: } | |
| 208 | 추가: } | |
| 209 | 추가: } | |
| 210 | 추가: #[test] | |
| 211 | 추가: fn preview_own_limit_is_not_expanded_by_permission() { | |
| 212 | 추가: for (name, bytes) in [ | |
| 213 | 추가: ( | |
| 214 | 추가: "payload.txt", | |
| 215 | 추가: vec![b'x'; MAX_PREVIEW_TEXT_BYTES as usize + 1], | |
| 216 | 추가: ), | |
| 217 | 추가: ("payload.png", vec![0; MAX_PREVIEW_IMAGE_BYTES as usize + 1]), | |
| 218 | 추가: ] { | |
| 219 | 추가: let (s, path, list, id) = fixture("zip", name, &bytes); | |
| 220 | 추가: let mut start = request(&s, &path, list, id); | |
| 221 | 추가: start.ceiling.output = 64 * 1024 * 1024 * 1024; | |
| 222 | 추가: let events = run(&s, start); | |
| 223 | 추가: assert!( | |
| 224 | 추가: events | |
| 225 | 추가: .iter() | |
| 226 | 추가: .any(|e| matches!(e, Message::ResourceRequired { .. })) | |
| 227 | 추가: ); | |
| 228 | 추가: no_result(&events, ErrorCode::Limit); | |
| 229 | 추가: } | |
| 230 | 추가: let expected = vec![b'x'; MAX_PREVIEW_TEXT_BYTES as usize]; | |
| 231 | 추가: let (s, path, list, id) = fixture("zip", "payload.txt", &expected); | |
| 232 | 추가: assert_eq!(result(&run(&s, request(&s, &path, list, id))).1, expected); | |
| 233 | 추가: } | |
| 234 | 추가: #[test] | |
| 235 | 추가: fn preview_rejects_corruption_unsupported_and_stale_selection() { | |
| 236 | 추가: for (name, bytes, error) in [ | |
| 237 | 추가: ("payload.txt", vec![0xff], ErrorCode::Integrity), | |
| 238 | 추가: ( | |
| 239 | 추가: "payload.svg", | |
| 240 | 추가: b"<svg/>".to_vec(), | |
| 241 | 추가: ErrorCode::UnsupportedFeature, | |
| 242 | 추가: ), | |
| 243 | 추가: ( | |
| 244 | 추가: "payload.png", | |
| 245 | 추가: b"GIF89a".to_vec(), | |
| 246 | 추가: ErrorCode::UnsupportedFormat, | |
| 247 | 추가: ), | |
| 248 | 추가: ("payload.jpg", vec![0xff, 0xd8], ErrorCode::Integrity), | |
| 249 | 추가: ] { | |
| 250 | 추가: let (s, path, list, id) = fixture("zip", name, &bytes); | |
| 251 | 추가: no_result(&run(&s, request(&s, &path, list, id)), error); | |
| 252 | 추가: } | |
| 253 | 추가: let (s, path, list, id) = fixture("zip", "payload.txt", b"text"); | |
| 254 | 추가: let mut changed = list.clone(); | |
| 255 | 추가: changed.archive_sha256[0] ^= 1; | |
| 256 | 추가: no_result( | |
| 257 | 추가: &run(&s, request(&s, &path, changed, id)), | |
| 258 | 추가: ErrorCode::SourceChanged, | |
| 259 | 추가: ); | |
| 260 | 추가: no_result( | |
| 261 | 추가: &run(&s, request(&s, &path, list, u32::MAX)), | |
| 262 | 추가: ErrorCode::InvalidRequest, | |
| 263 | 추가: ); | |
| 264 | 추가: } | |
| 265 | 추가: #[test] | |
| 266 | 추가: fn preview_solid_budget_still_applies_to_preceding_content() { | |
| 267 | 추가: let (s, path, list, id) = fixture("7z-lzma2", "payload.txt", b"text"); | |
| 268 | 추가: let mut start = request(&s, &path, list, id); | |
| 269 | 추가: start.start.limits.output = 100_000; | |
| 270 | 추가: start.ceiling = start.start.limits; | |
| 271 | 추가: no_result(&run(&s, start), ErrorCode::Limit); | |
| 272 | 추가: } | |
| 273 | 추가: #[test] | |
| 274 | 추가: fn preview_cancels_before_decode_and_during_chunk_transmission() { | |
| 275 | 추가: for stage in [0, 1, 2] { | |
| 276 | 추가: let (s, path, list, id) = fixture("zip", "payload.png", &png(4000, 4000)); | |
| 277 | 추가: let mut cancelled = false; | |
| 278 | 추가: let events = guarded::run(&s, request(&s, &path, list, id), |event| { | |
| 279 | 추가: let target = match stage { | |
| 280 | 추가: 0 => matches!(event, Message::Accepted { .. }), | |
| 281 | 추가: 1 => matches!( | |
| 282 | 추가: event, | |
| 283 | 추가: Message::Progress { | |
| 284 | 추가: stage: Stage::Decode, | |
| 285 | 추가: .. | |
| 286 | 추가: } | |
| 287 | 추가: ), | |
| 288 | 추가: _ => matches!(event, Message::PreviewChunk { .. }), | |
| 289 | 추가: }; | |
| 290 | 추가: if target && !cancelled { | |
| 291 | 추가: cancelled = true; | |
| 292 | 추가: Some(vec![Message::Cancel]) | |
| 293 | 추가: } else { | |
| 294 | 추가: None | |
| 295 | 추가: } | |
| 296 | 추가: }); | |
| 297 | 추가: assert!(cancelled); | |
| 298 | 추가: assert_eq!( | |
| 299 | 추가: terminal(&events).outcome, | |
| 300 | 추가: Outcome::Cancelled, | |
| 301 | 추가: "stage={stage}" | |
| 302 | 추가: ); | |
| 303 | 추가: assert_eq!(terminal(&events).publication, Publication::None); | |
| 304 | 추가: assert_eq!(terminal(&events).cleanup, Cleanup::Complete); | |
| 305 | 추가: assert!(!events.iter().any(|e| matches!(e, Message::Output { .. }))); | |
| 306 | 추가: } | |
| 307 | 추가: } | |
| 308 | 추가: | |
| 309 | 추가: #[test] | |
| 310 | 추가: fn preview_password_retry_and_cancel_never_publish_plaintext() { | |
| 311 | 추가: let (s, path, list, id) = fixture("aes", "payload.txt", b"secret preview"); | |
| 312 | 추가: let mut attempts = Vec::new(); | |
| 313 | 추가: let events = guarded::run( | |
| 314 | 추가: &s, | |
| 315 | 추가: request(&s, &path, list.clone(), id), | |
| 316 | 추가: |event| match event { | |
| 317 | 추가: Message::PasswordRequired { | |
| 318 | 추가: challenge_id, | |
| 319 | 추가: attempt, | |
| 320 | 추가: .. | |
| 321 | 추가: } => { | |
| 322 | 추가: attempts.push(*attempt); | |
| 323 | 추가: Some(vec![Message::Password { | |
| 324 | 추가: challenge_id: *challenge_id, | |
| 325 | 추가: secret: Secret(if *attempt == 1 { | |
| 326 | 추가: b"wrong".to_vec() | |
| 327 | 추가: } else { | |
| 328 | 추가: b"fixture-password".to_vec() | |
| 329 | 추가: }), | |
| 330 | 추가: }]) | |
| 331 | 추가: } | |
| 332 | 추가: _ => None, | |
| 333 | 추가: }, | |
| 334 | 추가: ); | |
| 335 | 추가: assert_eq!(attempts, [1, 2]); | |
| 336 | 추가: assert_eq!(result(&events).1, b"secret preview"); | |
| 337 | 추가: let events = guarded::run(&s, request(&s, &path, list, id), |event| { | |
| 338 | 추가: if matches!(event, Message::PasswordRequired { .. }) { | |
| 339 | 추가: Some(vec![Message::Cancel]) | |
| 340 | 추가: } else { | |
| 341 | 추가: None | |
| 342 | 추가: } | |
| 343 | 추가: }); | |
| 344 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Cancelled); | |
| 345 | 추가: assert!(!events.iter().any(|e| matches!( | |
| 346 | 추가: e, | |
| 347 | 추가: Message::PreviewBegin(_) | |
| 348 | 추가: | Message::PreviewChunk { .. } | |
| 349 | 추가: | Message::PreviewEnd { .. } | |
| 350 | 추가: | Message::Output { .. } | |
| 351 | 추가: ))); | |
| 352 | 추가: } | |
| 353 | 추가: | |
| 354 | 추가: #[test] | |
| 355 | 추가: fn preview_empty_text_uses_begin_and_end_without_chunks() { | |
| 356 | 추가: for format in ["zip", "tar", "7z-lzma2", "gzip"] { | |
| 357 | 추가: let (s, path, list, id) = fixture(format, "payload.txt", b""); | |
| 358 | 추가: let events = run(&s, request(&s, &path, list, id)); | |
| 359 | 추가: assert!(result(&events).1.is_empty()); | |
| 360 | 추가: assert!( | |
| 361 | 추가: !events | |
| 362 | 추가: .iter() | |
| 363 | 추가: .any(|e| matches!(e, Message::PreviewChunk { .. })) | |
| 364 | 추가: ); | |
| 365 | 추가: } | |
| 366 | 추가: } | |
| 367 | 추가: #[test] | |
| 368 | 추가: fn preview_rejects_directory_link_and_changed_source_object() { | |
| 369 | 추가: for format in ["tar-folder", "tar-link"] { | |
| 370 | 추가: let (s, path, list, id) = fixture(format, "payload.txt", b""); | |
| 371 | 추가: no_result( | |
| 372 | 추가: &run(&s, request(&s, &path, list, id)), | |
| 373 | 추가: ErrorCode::InvalidRequest, | |
| 374 | 추가: ); | |
| 375 | 추가: } | |
| 376 | 추가: let (s, path, list, id) = fixture("zip", "payload.txt", b"original"); | |
| 377 | 추가: fs::write(s.0.join(&path), b"changed").unwrap(); | |
| 378 | 추가: no_result( | |
| 379 | 추가: &run(&s, request(&s, &path, list, id)), | |
| 380 | 추가: ErrorCode::SourceChanged, | |
| 381 | 추가: ); | |
| 382 | 추가: assert_eq!(fs::read(s.0.join(&path)).unwrap(), b"changed"); | |
| 383 | 추가: } |
| @@ -2,6 +2,12 @@ | ||
| 2 | 2 | # It is not intended for manual editing. |
| 3 | 3 | version = 4 |
| 4 | 4 | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "adler2" | |
| 7 | 추가: version = "2.0.1" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" | |
| 10 | 추가: | |
| 5 | 11 | [[package]] |
| 6 | 12 | name = "aes" |
| 7 | 13 | version = "0.8.4" |
| @@ -14,6 +20,12 @@ dependencies = [ | ||
| 14 | 20 | "zeroize", |
| 15 | 21 | ] |
| 16 | 22 | |
| 23 | 추가: [[package]] | |
| 24 | 추가: name = "bitflags" | |
| 25 | 추가: version = "2.13.2" | |
| 26 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 27 | 추가: checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" | |
| 28 | 추가: | |
| 17 | 29 | [[package]] |
| 18 | 30 | name = "block-buffer" |
| 19 | 31 | version = "0.10.4" |
| @@ -81,6 +93,15 @@ dependencies = [ | ||
| 81 | 93 | "libc", |
| 82 | 94 | ] |
| 83 | 95 | |
| 96 | 추가: [[package]] | |
| 97 | 추가: name = "crc32fast" | |
| 98 | 추가: version = "1.5.5" | |
| 99 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 100 | 추가: checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" | |
| 101 | 추가: dependencies = [ | |
| 102 | 추가: "cfg-if", | |
| 103 | 추가: ] | |
| 104 | 추가: | |
| 84 | 105 | [[package]] |
| 85 | 106 | name = "crypto-common" |
| 86 | 107 | version = "0.1.7" |
| @@ -122,6 +143,26 @@ dependencies = [ | ||
| 122 | 143 | "crypto-common 0.2.2", |
| 123 | 144 | ] |
| 124 | 145 | |
| 146 | 추가: [[package]] | |
| 147 | 추가: name = "fdeflate" | |
| 148 | 추가: version = "0.3.7" | |
| 149 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 150 | 추가: checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" | |
| 151 | 추가: dependencies = [ | |
| 152 | 추가: "simd-adler32", | |
| 153 | 추가: ] | |
| 154 | 추가: | |
| 155 | 추가: [[package]] | |
| 156 | 추가: name = "flate2" | |
| 157 | 추가: version = "1.1.11" | |
| 158 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 159 | 추가: checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" | |
| 160 | 추가: dependencies = [ | |
| 161 | 추가: "crc32fast", | |
| 162 | 추가: "miniz_oxide 0.9.1", | |
| 163 | 추가: "zlib-rs", | |
| 164 | 추가: ] | |
| 165 | 추가: | |
| 125 | 166 | [[package]] |
| 126 | 167 | name = "generic-array" |
| 127 | 168 | version = "0.14.7" |
| @@ -180,6 +221,26 @@ dependencies = [ | ||
| 180 | 221 | "sha2 0.11.1", |
| 181 | 222 | ] |
| 182 | 223 | |
| 224 | 추가: [[package]] | |
| 225 | 추가: name = "miniz_oxide" | |
| 226 | 추가: version = "0.8.9" | |
| 227 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 228 | 추가: checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" | |
| 229 | 추가: dependencies = [ | |
| 230 | 추가: "adler2", | |
| 231 | 추가: "simd-adler32", | |
| 232 | 추가: ] | |
| 233 | 추가: | |
| 234 | 추가: [[package]] | |
| 235 | 추가: name = "miniz_oxide" | |
| 236 | 추가: version = "0.9.1" | |
| 237 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 238 | 추가: checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" | |
| 239 | 추가: dependencies = [ | |
| 240 | 추가: "adler2", | |
| 241 | 추가: "simd-adler32", | |
| 242 | 추가: ] | |
| 243 | 추가: | |
| 183 | 244 | [[package]] |
| 184 | 245 | name = "pbkdf2" |
| 185 | 246 | version = "0.12.2" |
| @@ -190,6 +251,19 @@ dependencies = [ | ||
| 190 | 251 | "hmac", |
| 191 | 252 | ] |
| 192 | 253 | |
| 254 | 추가: [[package]] | |
| 255 | 추가: name = "png" | |
| 256 | 추가: version = "0.18.1" | |
| 257 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 258 | 추가: checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" | |
| 259 | 추가: dependencies = [ | |
| 260 | 추가: "bitflags", | |
| 261 | 추가: "crc32fast", | |
| 262 | 추가: "fdeflate", | |
| 263 | 추가: "flate2", | |
| 264 | 추가: "miniz_oxide 0.8.9", | |
| 265 | 추가: ] | |
| 266 | 추가: | |
| 193 | 267 | [[package]] |
| 194 | 268 | name = "sha1" |
| 195 | 269 | version = "0.10.7" |
| @@ -223,6 +297,12 @@ dependencies = [ | ||
| 223 | 297 | "digest 0.11.3", |
| 224 | 298 | ] |
| 225 | 299 | |
| 300 | 추가: [[package]] | |
| 301 | 추가: name = "simd-adler32" | |
| 302 | 추가: version = "0.3.10" | |
| 303 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 304 | 추가: checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" | |
| 305 | 추가: | |
| 226 | 306 | [[package]] |
| 227 | 307 | name = "subtle" |
| 228 | 308 | version = "2.6.1" |
| @@ -256,11 +336,14 @@ dependencies = [ | ||
| 256 | 336 | "hmac", |
| 257 | 337 | "lzma-rust2", |
| 258 | 338 | "pbkdf2", |
| 339 | 추가: "png", | |
| 259 | 340 | "sha1", |
| 260 | 341 | "sha2 0.10.9", |
| 261 | 342 | "subtle", |
| 262 | 343 | "zeroize", |
| 263 | 344 | "zlib-rs", |
| 345 | 추가: "zune-core", | |
| 346 | 추가: "zune-jpeg", | |
| 264 | 347 | ] |
| 265 | 348 | |
| 266 | 349 | [[package]] |
| @@ -275,3 +358,18 @@ name = "zlib-rs" | ||
| 275 | 358 | version = "0.6.8" |
| 276 | 359 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 277 | 360 | checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| 361 | 추가: | |
| 362 | 추가: [[package]] | |
| 363 | 추가: name = "zune-core" | |
| 364 | 추가: version = "0.5.3" | |
| 365 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 366 | 추가: checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" | |
| 367 | 추가: | |
| 368 | 추가: [[package]] | |
| 369 | 추가: name = "zune-jpeg" | |
| 370 | 추가: version = "0.5.15" | |
| 371 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 372 | 추가: checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" | |
| 373 | 추가: dependencies = [ | |
| 374 | 추가: "zune-core", | |
| 375 | 추가: ] |
| @@ -2,6 +2,12 @@ | ||
| 2 | 2 | # It is not intended for manual editing. |
| 3 | 3 | version = 4 |
| 4 | 4 | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "adler2" | |
| 7 | 추가: version = "2.0.1" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" | |
| 10 | 추가: | |
| 5 | 11 | [[package]] |
| 6 | 12 | name = "aes" |
| 7 | 13 | version = "0.8.4" |
| @@ -14,6 +20,12 @@ dependencies = [ | ||
| 14 | 20 | "zeroize", |
| 15 | 21 | ] |
| 16 | 22 | |
| 23 | 추가: [[package]] | |
| 24 | 추가: name = "bitflags" | |
| 25 | 추가: version = "2.13.2" | |
| 26 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 27 | 추가: checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" | |
| 28 | 추가: | |
| 17 | 29 | [[package]] |
| 18 | 30 | name = "block-buffer" |
| 19 | 31 | version = "0.10.4" |
| @@ -81,6 +93,15 @@ dependencies = [ | ||
| 81 | 93 | "libc", |
| 82 | 94 | ] |
| 83 | 95 | |
| 96 | 추가: [[package]] | |
| 97 | 추가: name = "crc32fast" | |
| 98 | 추가: version = "1.5.5" | |
| 99 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 100 | 추가: checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" | |
| 101 | 추가: dependencies = [ | |
| 102 | 추가: "cfg-if", | |
| 103 | 추가: ] | |
| 104 | 추가: | |
| 84 | 105 | [[package]] |
| 85 | 106 | name = "crypto-common" |
| 86 | 107 | version = "0.1.7" |
| @@ -122,6 +143,26 @@ dependencies = [ | ||
| 122 | 143 | "crypto-common 0.2.2", |
| 123 | 144 | ] |
| 124 | 145 | |
| 146 | 추가: [[package]] | |
| 147 | 추가: name = "fdeflate" | |
| 148 | 추가: version = "0.3.7" | |
| 149 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 150 | 추가: checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" | |
| 151 | 추가: dependencies = [ | |
| 152 | 추가: "simd-adler32", | |
| 153 | 추가: ] | |
| 154 | 추가: | |
| 155 | 추가: [[package]] | |
| 156 | 추가: name = "flate2" | |
| 157 | 추가: version = "1.1.11" | |
| 158 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 159 | 추가: checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" | |
| 160 | 추가: dependencies = [ | |
| 161 | 추가: "crc32fast", | |
| 162 | 추가: "miniz_oxide 0.9.1", | |
| 163 | 추가: "zlib-rs", | |
| 164 | 추가: ] | |
| 165 | 추가: | |
| 125 | 166 | [[package]] |
| 126 | 167 | name = "generic-array" |
| 127 | 168 | version = "0.14.7" |
| @@ -180,6 +221,26 @@ dependencies = [ | ||
| 180 | 221 | "sha2 0.11.1", |
| 181 | 222 | ] |
| 182 | 223 | |
| 224 | 추가: [[package]] | |
| 225 | 추가: name = "miniz_oxide" | |
| 226 | 추가: version = "0.8.9" | |
| 227 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 228 | 추가: checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" | |
| 229 | 추가: dependencies = [ | |
| 230 | 추가: "adler2", | |
| 231 | 추가: "simd-adler32", | |
| 232 | 추가: ] | |
| 233 | 추가: | |
| 234 | 추가: [[package]] | |
| 235 | 추가: name = "miniz_oxide" | |
| 236 | 추가: version = "0.9.1" | |
| 237 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 238 | 추가: checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" | |
| 239 | 추가: dependencies = [ | |
| 240 | 추가: "adler2", | |
| 241 | 추가: "simd-adler32", | |
| 242 | 추가: ] | |
| 243 | 추가: | |
| 183 | 244 | [[package]] |
| 184 | 245 | name = "pbkdf2" |
| 185 | 246 | version = "0.12.2" |
| @@ -190,6 +251,19 @@ dependencies = [ | ||
| 190 | 251 | "hmac", |
| 191 | 252 | ] |
| 192 | 253 | |
| 254 | 추가: [[package]] | |
| 255 | 추가: name = "png" | |
| 256 | 추가: version = "0.18.1" | |
| 257 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 258 | 추가: checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" | |
| 259 | 추가: dependencies = [ | |
| 260 | 추가: "bitflags", | |
| 261 | 추가: "crc32fast", | |
| 262 | 추가: "fdeflate", | |
| 263 | 추가: "flate2", | |
| 264 | 추가: "miniz_oxide 0.8.9", | |
| 265 | 추가: ] | |
| 266 | 추가: | |
| 193 | 267 | [[package]] |
| 194 | 268 | name = "sha1" |
| 195 | 269 | version = "0.10.7" |
| @@ -223,6 +297,12 @@ dependencies = [ | ||
| 223 | 297 | "digest 0.11.3", |
| 224 | 298 | ] |
| 225 | 299 | |
| 300 | 추가: [[package]] | |
| 301 | 추가: name = "simd-adler32" | |
| 302 | 추가: version = "0.3.10" | |
| 303 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 304 | 추가: checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" | |
| 305 | 추가: | |
| 226 | 306 | [[package]] |
| 227 | 307 | name = "subtle" |
| 228 | 308 | version = "2.6.1" |
| @@ -256,11 +336,14 @@ dependencies = [ | ||
| 256 | 336 | "hmac", |
| 257 | 337 | "lzma-rust2", |
| 258 | 338 | "pbkdf2", |
| 339 | 추가: "png", | |
| 259 | 340 | "sha1", |
| 260 | 341 | "sha2 0.10.9", |
| 261 | 342 | "subtle", |
| 262 | 343 | "zeroize", |
| 263 | 344 | "zlib-rs", |
| 345 | 추가: "zune-core", | |
| 346 | 추가: "zune-jpeg", | |
| 264 | 347 | ] |
| 265 | 348 | |
| 266 | 349 | [[package]] |
| @@ -275,3 +358,18 @@ name = "zlib-rs" | ||
| 275 | 358 | version = "0.6.8" |
| 276 | 359 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 277 | 360 | checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| 361 | 추가: | |
| 362 | 추가: [[package]] | |
| 363 | 추가: name = "zune-core" | |
| 364 | 추가: version = "0.5.3" | |
| 365 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 366 | 추가: checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" | |
| 367 | 추가: | |
| 368 | 추가: [[package]] | |
| 369 | 추가: name = "zune-jpeg" | |
| 370 | 추가: version = "0.5.15" | |
| 371 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 372 | 추가: checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" | |
| 373 | 추가: dependencies = [ | |
| 374 | 추가: "zune-core", | |
| 375 | 추가: ] |