Add an Attachment to Evidence
Add an unstructured file as an evidence attachment in Artifactory.
You can attach one unstructured file, such as a PDF, a penetration test report, a signed contract, or an architectural diagram, while you create evidence. The signed, tamper-proof container holds your structured evidence and the unstructured file, and it keeps a complete audit trail. For example, attachments can be used in AppTrust for including required compliance documents. For more information, see Add Evidence Document to Application.
You can also use an attachment if your evidence file exceeds the 16 MB evidence payload limit.
The extended in-toto statement includes the attachment name, SHA256 checksum, and file type so the file stays intact.
You can add an attachment to your evidence using either method:
Tip
The evidence payload can't exceed 16 MB. If you need to create evidence from a larger file, use an evidence attachment.
Add an Evidence Attachment Using the REST APIs
Adding an attachment with the REST APIs takes three steps. The Prepare Evidence and Deploy Evidence REST APIs both support attachments.
Note
For more information, see Create Evidence Using REST APIs.
Upload the Attachment to Artifactory
Upload your attachment to a location you choose in JFrog Artifactory. For more information, see the Deploy Artifact API, or Deploy Artifacts for JFrog Platform UI instructions.
To upload the attachment to Artifactory:
- Upload the file to the repository path you choose.
Define the Attachment When Preparing Evidence
When using the Prepare Evidence REST API, include the uploaded attachment in the request.
To define the attachment when preparing evidence:
- Add the
repositoryandpathof the uploaded attachment to the request body. For example:
"attachments": [
{
"repository": "acme-prod-generic-local",
"path": "tmp/approval-frog-certificate.png"
}
]When you run it, the Prepare Evidence API adds the attachment name, SHA256 checksum, and file type to the Dead Simple Signing Envelope (DSSE). The repository, path, and SHA256 are included in its response.
{
"attachments": [
{
"repository": "acme-prod-generic-local",
"path": "tmp/approval-frog-certificate.png",
"sha256": "42281cf0e1a168bc766b1c143de8db334c36a5e6110df1b0c933b35f35411623"
}
]
}Add the Attachment During Deployment
After signing the payload, include the attachment in the Deploy Evidence request.
To add the attachment during deployment:
- Add the repository, path, and SHA256 of the attachment to the request body of the Deploy Evidence API. For example:
Request:
{
"payload": "eyJfdHlw....",
"payloadType": "application/vnd.in-toto+json",
"signatures": [
{
"keyid": "signing-key",
"sig": "MEQCIG..."
}
],
"attachments": [
{
"repository": "acme-prod-generic-local",
"path": "tmp/approval-frog-certificate.png",
"sha256": "42281cf0e1a168bc766b1c143de8db334c36a5e6110df1b0c933b35f35411623"
}
]
}Artifactory includes the attachment in the evidence, as the API response shows.
"attachments": [
{
"name": "approval-frog-certificate.png",
"sha256": "42281cf0e1a168bc766b1c143de8db334c36a5e6110df1b0c933b35f35411623",
"type": "application/octet-stream",
"download_path": "acme-prod-generic-local/.evidence/76ce53ecfbe0fd770edc76af31d022b5d17c7ced720be667ec83cd876ecf6708/7dbd94658f313ccfc811e28ad40408c48666dc9a19233d0a278140557d9a573f/attachments/8203f2f55d59970e4b6deed8a47f34f1b1beabbdfd43ae285b122eb197ef7c82-42281cf0e1a168bc766b1c143de8db33-approval-frog-certificate.png"
}
]Add an Evidence Attachment Using the JFrog CLI
The JFrog CLI parameters you use depend on whether the file is already in Artifactory.
Add an Attachment Located in Artifactory
To add an attachment located in Artifactory:
- Add
--attach-artifactory-pathto the Create Evidence CLI command. The value is the path and file name of the attachment.
For example:
jf evd create \
--subject-repo-path "acme-prod-generic-local/payments-service/1.8.15/payments-service-1.8.15.jar" \
--predicate "/path/to/predicate.json" \
--predicate-type "https://slsa.dev/provenance/v1" \
--attach-artifactory-path "acme-prod-generic-local/attachment.pdf"Add a Local Attachment
You can keep the attachment on a local drive. You don't have to upload it to Artifactory before you create the evidence.
To add a local attachment:
--attach-local: The path to the local file to attach to the evidence.--attach-artifactory-temp-path: The Artifactory repository path used for a temporary upload. After you set this property once, the value stays until you change it.
The CLI uploads the file to the designated temporary repository, creates the evidence, and moves the attachment to the evidence folder.
This example creates SLSA evidence with an attachment that contains a PNG image of an approval certificate:
jf evd create \
--subject-repo-path "acme-prod-generic-local/payments-service/1.8.15/payments-service-1.8.15.jar" \
--predicate "/path/to/predicate.json" \
--predicate-type "https://slsa.dev/provenance/v1" \
--attach-local "/path/to/attachment/file/approval-frog-certificate.png" \
--attach-artifactory-temp-path "example-repo-local/tmp/"In subsequent calls, --attach-artifactory-temp-path can be omitted for local attachments unless you decide to define a different temporary path.
For more information, see Create Evidence CLI.
Frequently Asked Questions
This section provides answers to frequently asked questions.
FAQs
Q: What can I use an evidence attachment for?
A: You can use an attachment to add any unstructured file, such as a PDF or a signed contract, to your evidence, regardless of its size. You can also add evidence that exceeds the maximum supported size (16 MB) as an attachment. For the REST API steps, see Add an Evidence Attachment Using the REST APIs.
Q: Can I attach a file that's already in Artifactory?
A: Yes. Add the --attach-artifactory-path parameter to the Create Evidence CLI command. See Add an Attachment Located in Artifactory.
Q: Does the CLI require me to upload a local file first?
A: No. The CLI uploads the file to the temporary repository that you set with --attach-artifactory-temp-path. See Add a Local Attachment.
Q: What does an attachment add to the evidence?
A: The attachment name, SHA256 checksum, and file type are added to the Dead Simple Signing Envelope (DSSE). See Define the Attachment When Preparing Evidence.
Q: Where do I upload the attachment for the REST APIs?
A: Upload it to a repository path that you choose in JFrog Artifactory. See Upload the Attachment to Artifactory.
Related Topics
Updated 10 days ago
