Skip to content

Commit 18ce87e

Browse files
committed
Add VMDK Test Image for OSV-Scalibr
Related PR: google/osv-scalibr#1295 Related issue: google/osv-scalibr#1215 Signed-off-by: Yuvraj Saxena <ysaxenax@gmail.com>
1 parent 594236f commit 18ce87e

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

vmdk/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt-get update
4+
5+
RUN mkdir -p /testdata
6+
7+
# Set working directory
8+
WORKDIR /testdata
9+
10+
# Copy valid .vmdk file into the container
11+
COPY valid-fat32-ext.vmdk /testdata/valid-fat32-ext.vmdk
12+
13+
CMD ["/bin/bash"]

vmdk/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# OSV-Scalibr: VMDK Extractor
2+
3+
This directory contains a test Dockerfile for validating OSV-Scalibr's VMDK Extractor plugin. A VMDK (Virtual Machine Disk) file is a disk image format commonly used by virtual machines to emulate a physical hard drive.
4+
5+
## Setup
6+
7+
### Build the Docker Image
8+
9+
```bash
10+
cd security-testbeds/vmdk
11+
docker build -t vmdk-extractor-testbed .
12+
```
13+
14+
### Run the Container
15+
16+
```bash
17+
docker run -it --rm vmdk-extractor-testbed /bin/bash
18+
```
19+
20+
### Running OSV-Scalibr
21+
22+
Build or copy the `scalibr` binary to the current directory, and inside the container, run `scalibr` with the vmdk extractor:
23+
24+
```bash
25+
./scalibr --extractors=embeddedfs/vmdk --result=output.textproto valid-fat32-ext.vmdk
26+
```

vmdk/genvmdk.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
dd if=/dev/zero of=valid.img bs=1M count=256
4+
parted -s --align optimal valid.img --script mklabel gpt
5+
parted -s --align optimal valid.img --script mkpart primary ext4 0% 25%
6+
parted -s --align optimal valid.img --script mkpart primary ntfs 25% 100%
7+
parted -s --align optimal valid.img --script set 2 msftdata on
8+
sudo losetup -fP valid.img
9+
LOOPDEV=$(losetup -j valid.img | cut -d: -f1)
10+
PARTITION1="${LOOPDEV}p1"
11+
PARTITION2="${LOOPDEV}p2"
12+
sudo mkfs.ext4 $PARTITION1
13+
sudo mkfs.vfat -F 32 $PARTITION2
14+
sudo rm -rf /mnt/valid*
15+
sudo mkdir /mnt/valid1
16+
sudo mkdir /mnt/valid2
17+
sudo mount ${PARTITION1} /mnt/valid1
18+
sudo mount ${PARTITION2} /mnt/valid2
19+
openssl genrsa -out private-key.pem 4096
20+
sudo cp private-key.pem /mnt/valid1/private-key1.pem
21+
sudo cp private-key.pem /mnt/valid2/private-key2.pem
22+
sudo umount /mnt/valid1
23+
sudo umount /mnt/valid2
24+
sudo losetup -d ${LOOPDEV}
25+
sudo rm -rf /mnt/valid*
26+
sudo rm -f valid.img
27+
qemu-img convert valid.img -O vmdk valid-fat32-ext.vmdk
28+
rm private-key.pem

vmdk/valid-fat32-ext.vmdk

832 KB
Binary file not shown.

0 commit comments

Comments
 (0)