Skip to content

Commit 286b37b

Browse files
committed
Merge branch 'main' into gpeacock/builder_fixes
2 parents 120e6fd + ec6cbdb commit 286b37b

File tree

4 files changed

+79
-19
lines changed

4 files changed

+79
-19
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
name: Build
22

33
on:
4+
pull_request:
45
push:
56
branches:
67
- main
78
tags:
89
- "*"
910
workflow_dispatch:
10-
11-
permissions:
12-
contents: read
11+
inputs:
12+
publish:
13+
description: 'Publish'
14+
required: true
15+
default: 'false'
1316

1417
jobs:
1518
linux:
@@ -18,8 +21,8 @@ jobs:
1821
matrix:
1922
target: [x86_64, aarch64]
2023
steps:
21-
- uses: actions/checkout@v3
22-
- uses: actions/setup-python@v4
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v5
2326
with:
2427
python-version: "3.10"
2528
cache: "pip"
@@ -35,7 +38,24 @@ jobs:
3538
args: --release --out dist --find-interpreter
3639
sccache: "true"
3740
manylinux: ${{ matrix.target == 'aarch64' && 'manylinux_2_28' || 'auto' }}
38-
before-script-linux: "pip install uniffi-bindgen==0.24.1"
41+
before-script-linux: |
42+
pip install uniffi-bindgen==0.24.1
43+
44+
# ISSUE: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145
45+
# If we're running on rhel centos, install needed packages.
46+
if command -v yum &> /dev/null; then
47+
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic
48+
49+
# If we're running on i686 we need to symlink libatomic
50+
# in order to build openssl with -latomic flag.
51+
if [[ ! -d "/usr/lib64" ]]; then
52+
ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so
53+
fi
54+
else
55+
# If we're running on debian-based system.
56+
apt update -y && apt-get install -y libssl-dev openssl pkg-config
57+
fi
58+
3959
- name: Upload wheels
4060
uses: actions/upload-artifact@v3
4161
with:
@@ -48,8 +68,8 @@ jobs:
4868
matrix:
4969
target: [x64, x86]
5070
steps:
51-
- uses: actions/checkout@v3
52-
- uses: actions/setup-python@v4
71+
- uses: actions/checkout@v4
72+
- uses: actions/setup-python@v5
5373
with:
5474
python-version: '3.10'
5575
architecture: ${{ matrix.target }}
@@ -70,8 +90,8 @@ jobs:
7090
macos_x86:
7191
runs-on: macos-latest
7292
steps:
73-
- uses: actions/checkout@v3
74-
- uses: actions/setup-python@v4
93+
- uses: actions/checkout@v4
94+
- uses: actions/setup-python@v5
7595
with:
7696
python-version: '3.10'
7797
cache: "pip"
@@ -91,8 +111,8 @@ jobs:
91111
macos_aarch64:
92112
runs-on: macos-latest-large
93113
steps:
94-
- uses: actions/checkout@v3
95-
- uses: actions/setup-python@v4
114+
- uses: actions/checkout@v4
115+
- uses: actions/setup-python@v5
96116
with:
97117
python-version: '3.10'
98118
cache: "pip"
@@ -112,7 +132,7 @@ jobs:
112132
sdist:
113133
runs-on: ubuntu-latest
114134
steps:
115-
- uses: actions/checkout@v3
135+
- uses: actions/checkout@v4
116136
- name: Build sdist
117137
uses: PyO3/maturin-action@v1
118138
with:
@@ -128,7 +148,7 @@ jobs:
128148
name: Release
129149
runs-on: ubuntu-latest
130150
environment: Publish
131-
if: "startsWith(github.ref, 'refs/tags/')"
151+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true'
132152
needs: [linux, windows, macos_x86, macos_aarch64, sdist]
133153
steps:
134154
- uses: actions/download-artifact@v3

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ feel free to reach out to existing committers to have a conversation about that.
7878

7979
## Security issues
8080

81-
Security issues shouldn't be reported on this issue tracker. Instead,
82-
[file an issue to our security experts](https://helpx.adobe.com/security/alertus.html).
81+
Do not create a public GitHub issue for any suspected security vulnerabilities. Instead, please file an issue through [Adobe's HackerOne page](https://hackerone.com/adobe?type=team).
82+
For more information on reporting security issues, see [SECURITY.md](SECURITY.md).

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Import the API as follows:
3636
from c2pa import *
3737
```
3838

39-
### Read and validate C2PA data in a file
39+
### Read and validate C2PA data in a file or stream
4040

4141
Use the `Reader` to read C2PA data from the specified file.
4242
This examines the specified media file for C2PA data and generates a report of any data it finds. If there are validation errors, the report includes a `validation_status` field. For a summary of supported media types, see [Supported file formats](#supported-file-formats).
@@ -48,7 +48,12 @@ The manifests may contain binary resources such as thumbnails which can be retri
4848
NOTE: For a comprehensive reference to the JSON manifest structure, see the [Manifest store reference](https://opensource.contentauthenticity.org/docs/manifest/manifest-ref).
4949
```py
5050
try:
51-
reader = c2pa.Reader("path/to/media_file.jpg")
51+
# Create a reader from a file path
52+
reader = c2pa.Reader.from_file("path/to/media_file.jpg")
53+
# It's also possible to create a reader from a format and stream
54+
# Note that these two readers are functionally equivalent
55+
stream = open("path/to/media_file.jpg", "rb")
56+
reader = c2pa.Reader("image/jpeg", stream)
5257

5358
# Print the JSON for a manifest.
5459
print("manifest store:", reader.json())
@@ -65,7 +70,7 @@ except Exception as err:
6570
print(err)
6671
```
6772

68-
### Add a signed manifest to a media file
73+
### Add a signed manifest to a media file or stream
6974

7075
Use a `Builder` to add a manifest to an asset.
7176

@@ -115,6 +120,10 @@ try:
115120
# The uri provided here "thumbnail" must match an identifier in the manifest definition.
116121
builder.add_resource_file("thumbnail", "tests/fixtures/A_thumbnail.jpg")
117122

123+
# Or add the resource from a stream
124+
a_thumbnail_jpg_stream = open("tests/fixtures/A_thumbnail.jpg", "rb")
125+
builder.add_resource("image/jpeg", a_thumbnail_jpg_stream)
126+
118127
# Define an ingredient, in this case a parent ingredient named A.jpg, with a thumbnail
119128
ingredient_json = {
120129
"title": "A.jpg",
@@ -128,6 +137,10 @@ try:
128137
# Add the ingredient to the builder loading information from a source file.
129138
builder.add_ingredient_file(ingredient_json, "tests/fixtures/A.jpg")
130139

140+
# Or add the ingredient from a stream
141+
a_jpg_stream = open("tests/fixtures/A.jpg", "rb")
142+
builder.add_ingredient("image/jpeg", a_jpg_stream)
143+
131144
# At this point we could archive or unarchive our Builder to continue later.
132145
# In this example we use a bytearray for the archive stream.
133146
# all ingredients and resources will be saved in the archive
@@ -140,6 +153,11 @@ try:
140153
# This returns the binary manifest data that could be uploaded to cloud storage.
141154
c2pa_data = builder.sign_file(signer, "tests/fixtures/A.jpg", "target/out.jpg")
142155

156+
# Or sign the builder with a stream and output it to a stream
157+
input_stream = open("tests/fixtures/A.jpg", "rb")
158+
output_stream = open("target/out.jpg", "wb")
159+
c2pa_data = builder.sign(signer, "image/jpeg", input_stream, output_stream)
160+
143161
except Exception as err:
144162
print(err)
145163
```

SECURITY.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Security
2+
3+
This C2PA open-source library is maintained in partnership with Adobe. At this time, Adobe is taking point on accepting security reports through its HackerOne portal and public bug bounty program.
4+
5+
## Reporting a vulnerability
6+
7+
Please do not create a public GitHub issue for any suspected security vulnerabilities. Instead, please file an issue through [Adobe's HackerOne page](https://hackerone.com/adobe?type=team). If for some reason this is not possible, reach out to [email protected].
8+
9+
10+
## Vulnerability SLAs
11+
12+
Once we receive an actionable vulnerability (meaning there is an available patch, or a code fix is required), we will acknowledge the vulnerability within 24 hours. Our target SLAs for resolution are:
13+
14+
1. 72 hours for vulnerabilities with a CVSS score of 9.0-10.0
15+
2. 2 weeks for vulnerabilities with a CVSS score of 7.0-8.9
16+
17+
Any vulnerability with a score below 6.9 will be resolved when possible.
18+
19+
20+
## C2PA Vulnerabilities
21+
22+
This library is not meant to address any potential vulnerabilities within the C2PA specification itself. It is only an implementation of the spec as written. Any suspected vulnerabilities within the spec can be reported [here](https://github.com/c2pa-org/specifications/issues).

0 commit comments

Comments
 (0)