Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Decouple asset_handlers into c2pa-codecs crate #533

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[workspace]
resolver = "2"
members = ["sdk", "export_schema", "make_test_images"]
members = [
"sdk",
"export_schema",
"make_test_images",
"sdk/crates/*",
# TODO: add wildcard
"sdk/crates/c2pa-codecs/fuzz",
]
59 changes: 59 additions & 0 deletions sdk/crates/c2pa-codecs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[package]
name = "c2pa-codecs"
version = "0.1.0"
edition = "2021"

[dependencies]
thiserror = "1.0.61"
# TODO: need?
memchr = "2.7.1"
# TODO: unneeded and super unmaintained
conv = "0.3.3"
# TODO: remove this
tempfile = "3.10.1"
byteorder = { version = "1.4.3", default-features = false }
# TODO: do we need
serde_bytes = { version = "0.11.5", optional = true }
# TODO: temp
serde = { version = "1.0.197", features = ["derive"] }
# TODO: unmaintained
atree = "0.5.2"
# TODO: this crate is deprecated, use quick-xml
fast-xml = { version = "0.23.1", optional = true }
quick-xml = { version = "0.36.1", optional = true }
lopdf = { version = "0.31.0", optional = true }
# Version 1.13.0 doesn't compile under Rust < 1.75, pinning to 1.12.0
id3 = { version = "=1.12.0", optional = true }
png_pong = { version = "0.9.1", optional = true }
# TODO: sort of unmaintained
img-parts = { version = "0.3.0", optional = true }
# TODO: sort of unmaintained
riff = { version = "1.0.1", optional = true }
# TODO: needed?
base64 = { version = "0.21.2", optional = true }
# TODO: look into
jfifdump = { version = "0.5.1", optional = true }

[features]
default = [
"bmff",
"gif",
"jpeg",
"mp3",
"pdf",
"png",
"riff",
"svg",
"tiff",
"xmp",
]
xmp = ["fast-xml"]
bmff = []
gif = []
jpeg = ["img-parts", "jfifdump"]
mp3 = ["id3"]
pdf = ["lopdf"]
png = ["png_pong", "img-parts"] # TODO: remove img-parts feature here
riff = ["dep:riff"]
svg = ["fast-xml", "base64"]
tiff = []
8 changes: 8 additions & 0 deletions sdk/crates/c2pa-codecs/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "c2pa-codecs-fuzz"
version = "0.1.0"
edition = "2021"

[dependencies]
afl = "0.15.10"
c2pa-codecs = { path = ".." }
25 changes: 25 additions & 0 deletions sdk/crates/c2pa-codecs/fuzz/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::io::Cursor;

use c2pa_codecs::{
codecs::{gif::GifCodec, svg::SvgCodec},
Decode,
};

// TODO: add all codecs and add way to choose what to fuzz, reading/writing/c2pa/xmp/etc.
fn main() {
afl::fuzz!(|data: &[u8]| {
let src = Cursor::new(data);

// let mut c = GifCodec::new(src);
// let _ = c.read_c2pa();
// let _ = c.read_xmp();

let mut c = SvgCodec::new(src);
let _ = c.read_c2pa();
let _ = c.read_xmp();

// let mut c = C2paCodec::new(src);
// let _ = c.read_c2pa();
// let _ = c.read_xmp();
});
}
Loading
Loading