-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add additional ELF fields to test fixture
Signed-off-by: Alex Goodman <[email protected]>
- Loading branch information
Showing
5 changed files
with
25 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,37 +15,39 @@ func Test_ELF_Package_Cataloger(t *testing.T) { | |
Version: "0.01", | ||
PURL: "pkg:generic/syftsys/[email protected]", | ||
FoundBy: "", | ||
Locations: file.NewLocationSet(file.NewVirtualLocation("/usr/local/bin/elftests/elfbinwithnestedlib/bin/lib/libhello_world.so", "/usr/local/bin/elftests/elfbinwithnestedlib/bin/lib/libhello_world.so"), | ||
Locations: file.NewLocationSet( | ||
file.NewVirtualLocation("/usr/local/bin/elftests/elfbinwithnestedlib/bin/lib/libhello_world.so", "/usr/local/bin/elftests/elfbinwithnestedlib/bin/lib/libhello_world.so"), | ||
file.NewVirtualLocation("/usr/local/bin/elftests/elfbinwithsisterlib/lib/libhello_world.so", "/usr/local/bin/elftests/elfbinwithsisterlib/lib/libhello_world.so"), | ||
file.NewVirtualLocation("/usr/local/bin/elftests/elfbinwithsisterlib/lib/libhello_world2.so", "/usr/local/bin/elftests/elfbinwithsisterlib/lib/libhello_world2.so"), | ||
), | ||
Language: "", | ||
Type: pkg.BinaryPkg, | ||
Metadata: pkg.ELFBinaryPackageNotes{ | ||
Type: "testfixture", | ||
Vendor: "syft", | ||
System: "syftsys", | ||
Source: "", | ||
Commit: "", | ||
Type: "testfixture", | ||
Vendor: "syft", | ||
System: "syftsys", | ||
SourceRepo: "https://github.com/someone/somewhere.git", | ||
Commit: "5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb", | ||
}, | ||
}, | ||
{ | ||
Name: "syfttestfixture", | ||
Version: "0.01", | ||
PURL: "pkg:generic/syftsys/[email protected]", | ||
FoundBy: "", | ||
Locations: file.NewLocationSet(file.NewLocation("/usr/local/bin/elftests/elfbinwithnestedlib/bin/elfbinwithnestedlib").WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation), | ||
Locations: file.NewLocationSet( | ||
file.NewLocation("/usr/local/bin/elftests/elfbinwithnestedlib/bin/elfbinwithnestedlib").WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation), | ||
file.NewLocation("/usr/local/bin/elftests/elfbinwithsisterlib/bin/elfwithparallellibbin1").WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation), | ||
file.NewLocation("/usr/local/bin/elftests/elfbinwithsisterlib/bin/elfwithparallellibbin2").WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation), | ||
), | ||
Language: "", | ||
Type: pkg.BinaryPkg, | ||
Metadata: pkg.ELFBinaryPackageNotes{ | ||
Type: "testfixture", | ||
Vendor: "syft", | ||
System: "syftsys", | ||
Source: "", | ||
Commit: "", | ||
Type: "testfixture", | ||
Vendor: "syft", | ||
System: "syftsys", | ||
SourceRepo: "https://github.com/someone/somewhere.git", | ||
Commit: "5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb", | ||
}, | ||
}, | ||
} | ||
|
@@ -56,69 +58,4 @@ func Test_ELF_Package_Cataloger(t *testing.T) { | |
Expects(expectedPkgs, nil). | ||
TestCataloger(t, NewELFPackageCataloger()) | ||
|
||
// expectedPkgs = []pkg.Package{ | ||
// { | ||
// Name: "libhello_world.so", | ||
// Version: "0.01", | ||
// PURL: "pkg:generic/syftsys/[email protected]", | ||
// FoundBy: "", | ||
// Locations: file.NewLocationSet(file.NewVirtualLocation("/usr/local/bin/syftelftest/lib/libhello_world.so", "/usr/local/bin/syftelftest/lib/libhello_world.so")), | ||
// Language: "", | ||
// Type: pkg.BinaryPkg, | ||
// Metadata: pkg.ELFBinaryPackageNotes{ | ||
// Type: "testfixture", | ||
// Vendor: "syft", | ||
// System: "syftsys", | ||
// }, | ||
// }, | ||
// { | ||
// Name: "syfttestfixture", | ||
// Version: "0.01", | ||
// PURL: "pkg:generic/syftsys/[email protected]", | ||
// FoundBy: "", | ||
// Locations: file.NewLocationSet(file.NewVirtualLocation("/usr/local/bin/syftelftest/bin/elfwithparallellibbin1", "/usr/local/bin/syftelftest/bin/elfwithparallellibbin1")), | ||
// Language: "", | ||
// Type: pkg.BinaryPkg, | ||
// Metadata: pkg.ELFBinaryPackageNotes{ | ||
// Type: "testfixture", | ||
// Vendor: "syft", | ||
// System: "syftsys", | ||
// }, | ||
// }, | ||
// { | ||
// Name: "libhello_world2.so", | ||
// Version: "0.01", | ||
// PURL: "pkg:generic/syftsys/[email protected]", | ||
// FoundBy: "", | ||
// Locations: file.NewLocationSet(file.NewVirtualLocation("/usr/local/bin/syftelftest/lib/libhello_world2.so", "/usr/local/bin/syftelftest/lib/libhello_world2.so")), | ||
// Language: "", | ||
// Type: pkg.BinaryPkg, | ||
// Metadata: pkg.ELFBinaryPackageNotes{ | ||
// Type: "testfixture", | ||
// Vendor: "syft", | ||
// System: "syftsys", | ||
// }, | ||
// }, | ||
|
||
// { | ||
// Name: "syfttestfixture", | ||
// Version: "0.01", | ||
// PURL: "pkg:generic/syftsys/[email protected]", | ||
// FoundBy: "", | ||
// Locations: file.NewLocationSet(file.NewVirtualLocation("/usr/local/bin/syftelftest/bin/elfwithparallellibbin2", "/usr/local/bin/syftelftest/bin/elfwithparallellibbin2")), | ||
// Language: "", | ||
// Type: pkg.BinaryPkg, | ||
// Metadata: pkg.ELFBinaryPackageNotes{ | ||
// Type: "testfixture", | ||
// Vendor: "syft", | ||
// System: "syftsys", | ||
// }, | ||
// }, | ||
// } | ||
// pkgtest.NewCatalogTester(). | ||
// WithImageResolver(t, "elf-test-fixture-sister-lib"). | ||
// IgnoreLocationLayer(). // this fixture can be rebuilt, thus the layer ID will change | ||
// Expects(expectedPkgs, nil). | ||
// TestCataloger(t, NewELFPackageCataloger()) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ all: testfixture | |
|
||
$(LIB_SO): $(LIB_OBJ) | $(LIB_DIR) | ||
$(CC) -shared -o $@ $< | ||
echo '{"type": "testfixture","vendor": "syft","system": "syftsys","name": "libhello_world.so","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
echo '{"type": "testfixture","license":"MIT","commit":"5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb","sourceRepo":"https://github.com/someone/somewhere.git","vendor": "syft","system": "syftsys","name": "libhello_world.so","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
|
||
$(LIB_OBJ): $(LIB_SRC) | $(BUILD_DIR) | ||
$(CC) $(CFLAGS) -fPIC -c $< -o $@ | ||
|
@@ -37,7 +37,7 @@ $(LIB_DIR): | |
|
||
$(BIN_DIR)/$(EXECUTABLE): $(EXEC_OBJ) $(LIB_SO) | $(BIN_DIR) | ||
$(CC) $(CFLAGS) -o $@ $^ -L$(LIB_DIR) -l$(LIB_NAME) $(LDFLAGS) | ||
echo '{"type": "testfixture","vendor": "syft","system": "syftsys","name": "syfttestfixture","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
echo '{"type": "testfixture","license":"MIT","commit":"5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb","sourceRepo":"https://github.com/someone/somewhere.git","vendor": "syft","system": "syftsys","name": "syfttestfixture","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
|
||
testfixture: $(BIN_DIR)/$(EXECUTABLE) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ all: testfixture | |
|
||
$(LIB_SO): $(LIB_OBJ) | $(LIB_DIR) | ||
$(CC) -shared -o $@ $< | ||
echo '{"type": "testfixture","vendor": "syft","system": "syftsys","name": "libhello_world.so","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
echo '{"type": "testfixture","license":"MIT","commit":"5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb","sourceRepo":"https://github.com/someone/somewhere.git","vendor": "syft","system": "syftsys","name": "libhello_world.so","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
|
||
$(LIB_OBJ): $(LIB_SRC) | $(BUILD_DIR) | ||
$(CC) $(CFLAGS) -fPIC -c $< -o $@ | ||
|
@@ -37,7 +37,7 @@ $(LIB_DIR): | |
|
||
$(BIN_DIR)/$(EXECUTABLE): $(EXEC_OBJ) $(LIB_SO) | $(BIN_DIR) | ||
$(CC) $(CFLAGS) -o $@ $^ -L$(LIB_DIR) -l$(LIB_NAME) $(LDFLAGS) | ||
echo '{"type": "testfixture","vendor": "syft","system": "syftsys","name": "syfttestfixture","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
echo '{"type": "testfixture","license":"MIT","commit":"5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb","sourceRepo":"https://github.com/someone/somewhere.git","vendor": "syft","system": "syftsys","name": "syfttestfixture","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
|
||
testfixture: $(BIN_DIR)/$(EXECUTABLE) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ all: testfixture | |
|
||
$(LIB_SO): $(LIB_OBJ) | $(LIB_DIR) | ||
$(CC) -shared -o $@ $< | ||
echo '{"type": "testfixture","vendor": "syft","system": "syftsys","name": "libhello_world.so","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
echo '{"type": "testfixture","license":"MIT","commit":"5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb","sourceRepo":"https://github.com/someone/somewhere.git","vendor": "syft","system": "syftsys","name": "libhello_world.so","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
|
||
$(LIB_OBJ): $(LIB_SRC) | $(BUILD_DIR) | ||
$(CC) $(CFLAGS) -fPIC -c $< -o $@ | ||
|
@@ -37,7 +37,7 @@ $(LIB_DIR): | |
|
||
$(BIN_DIR)/$(EXECUTABLE): $(EXEC_OBJ) $(LIB_SO) | $(BIN_DIR) | ||
$(CC) $(CFLAGS) -o $@ $^ -L$(LIB_DIR) -l$(LIB_NAME) $(LDFLAGS) | ||
echo '{"type": "testfixture","vendor": "syft","system": "syftsys","name": "syfttestfixture","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
echo '{"type": "testfixture","license":"MIT","commit":"5534c38d0ffef9a3f83154f0b7a7fb6ab0ab6dbb","sourceRepo":"https://github.com/someone/somewhere.git","vendor": "syft","system": "syftsys","name": "syfttestfixture","version": "0.01","purl": "pkg:generic/syftsys/[email protected]","cpe": "cpe:/o:syft:syftsys_testfixture_syfttestfixture:0.01"}' | objcopy --add-section .note.package=/dev/stdin --set-section-flags .note.package=noload,readonly $@ | ||
|
||
testfixture: $(BIN_DIR)/$(EXECUTABLE) | ||
|
||
|