-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
170 additions
and
73 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule SBoM.Cpe do | ||
@moduledoc false | ||
|
||
def hex(name, version, repo \\ "hexpm") do | ||
do_hex(String.downcase(name), version, String.downcase(repo)) | ||
end | ||
|
||
defp do_hex("hex_core", version, "hexpm") do | ||
"cpe:2.3:a:hex:hex_core:#{version}:*:*:*:*:*:*:*" | ||
end | ||
|
||
defp do_hex("plug", version, "hexpm") do | ||
"cpe:2.3:a:elixir-plug:plug:#{version}:*:*:*:*:*:*:*" | ||
end | ||
|
||
defp do_hex("phoenix", version, "hexpm") do | ||
"cpe:2.3:a:phoenixframework:phoenix:#{version}:*:*:*:*:*:*:*" | ||
end | ||
|
||
defp do_hex("coherence", version, "hexpm") do | ||
"cpe:2.3:a:coherence_project:coherence:#{version}:*:*:*:*:*:*:*" | ||
end | ||
|
||
defp do_hex("xain", version, "hexpm") do | ||
"cpe:2.3:a:emetrotel:xain:#{version}:*:*:*:*:*:*:*" | ||
end | ||
|
||
defp do_hex("sweet_xml", version, "hexpm") do | ||
"cpe:2.3:a:kbrw:sweet_xml:#{version}:*:*:*:*:*:*:*" | ||
end | ||
|
||
defp do_hex(_name, _version, _repo), do: nil | ||
end |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
defmodule SBoM.MixProject do | ||
use Mix.Project | ||
|
||
@version "0.5.1" | ||
@version "0.6.0" | ||
|
||
def project do | ||
[ | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defmodule Mix.Tasks.Sbom.CyclonedxTest do | ||
use ExUnit.Case | ||
|
||
setup_all do | ||
Mix.shell(Mix.Shell.Process) | ||
:ok | ||
end | ||
|
||
setup do | ||
Mix.Shell.Process.flush() | ||
:ok | ||
end | ||
|
||
test "mix task" do | ||
Mix.Project.in_project(__MODULE__, "test/fixtures/sample1", fn _mod -> | ||
Mix.Task.rerun("deps.clean", ["--all"]) | ||
|
||
assert_raise Mix.Error, "Can't continue due to errors on dependencies", fn -> | ||
Mix.Task.rerun("sbom.cyclonedx", ["-d", "-f"]) | ||
end | ||
|
||
Mix.Task.rerun("deps.get") | ||
Mix.Shell.Process.flush() | ||
|
||
Mix.Task.rerun("sbom.cyclonedx", ["-d", "-f"]) | ||
assert_received {:mix_shell, :info, ["* creating bom.xml"]} | ||
end) | ||
end | ||
end |
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ defmodule SBoM.CycloneDXTest do | |
assert xml =~ ~s(<name>name</name>) | ||
assert xml =~ ~s(<version>0.0.1</version>) | ||
assert xml =~ ~s(<purl>pkg:hex/[email protected]</purl>) | ||
assert xml =~ ~s(<licenses/>) | ||
refute xml =~ ~s(<licenses>) | ||
end | ||
|
||
test "component with SPDX license" do | ||
|
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