Skip to content

Commit

Permalink
Do not use effect.NewExecutor use CommandExecutor instead
Browse files Browse the repository at this point in the history
When running `syft`, do not use effect.NewExecutor which runs the command with a tty. This seems to cause an issue with syft (or possibly with our tty library pty), and in either case you end up with stray formatting characters even though we tell syft to be quiet. Using CommandExecutor is basically the same, but it doesn't run with a tty.

Signed-off-by: Daniel Mikusa <[email protected]>
  • Loading branch information
dmikusa committed Oct 4, 2024
1 parent 9103362 commit 9a687e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion maven/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
if _, found, err := pr.Resolve(PlanEntryJVMApplicationPackage); err != nil {
return libcnb.BuildResult{}, fmt.Errorf("unable to resolve JVM Application Package plan entry\n%w", err)
} else if found {
bomScanner := sbom.NewSyftCLISBOMScanner(context.Layers, effect.NewExecutor(), b.Logger)
bomScanner := sbom.NewSyftCLISBOMScanner(context.Layers, effect.CommandExecutor{}, b.Logger)

// build a layer contributor to run Maven
a, err := b.ApplicationFactory.NewApplication(
Expand Down
22 changes: 12 additions & 10 deletions maven/maven_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func testMavenManager(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect

ctx libcnb.BuildContext
mavenManager maven.MavenManager
mvnwFilepath string
ctx libcnb.BuildContext
mavenManager maven.MavenManager
mvnwFilepath string
mvnwPropsPath string
)

Expand All @@ -36,10 +36,12 @@ func testMavenManager(t *testing.T, context spec.G, it spec.S) {
Expect(err).NotTo(HaveOccurred())

mvnwFilepath = filepath.Join(ctx.Application.Path, "mvnw")
mvnwPropsPath = filepath.Join(ctx.Application.Path, ".mvn/wrapper/")
mvnwPropsPath = filepath.Join(ctx.Application.Path, ".mvn/wrapper/")

err = os.MkdirAll(mvnwPropsPath, 0755)
Expect(err).NotTo(HaveOccurred())

t.Setenv("BP_ARCH", "amd64")
})

it.After(func() {
Expand Down Expand Up @@ -273,13 +275,13 @@ func testMavenManager(t *testing.T, context spec.G, it spec.S) {
it("converts CRLF formatting in the maven-wrapper.properties file to LF (unix) if present", func() {
propsFile := filepath.Join(mvnwPropsPath, "maven-wrapper.properties")
Expect(os.WriteFile(propsFile, []byte("test\r\n"), 0755)).To(Succeed())

_, _, _, err := mavenManager.Install()
Expect(err).NotTo(HaveOccurred())
Expect(err).NotTo(HaveOccurred())

contents, err := os.ReadFile(propsFile)
Expect(err).NotTo(HaveOccurred())
Expect(bytes.Compare(contents, []byte("test\n"))).To(Equal(0))
contents, err := os.ReadFile(propsFile)
Expect(err).NotTo(HaveOccurred())
Expect(bytes.Compare(contents, []byte("test\n"))).To(Equal(0))
})

})
Expand Down

0 comments on commit 9a687e2

Please sign in to comment.