github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/syft/pkg/cataloger/elixir/parse_mix_lock_test.go (about)

     1  package elixir
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/anchore/syft/syft/artifact"
     7  	"github.com/anchore/syft/syft/file"
     8  	"github.com/anchore/syft/syft/pkg"
     9  	"github.com/lineaje-labs/syft/syft/pkg/cataloger/internal/pkgtest"
    10  )
    11  
    12  func TestParseMixLock(t *testing.T) {
    13  	locations := file.NewLocationSet(file.NewLocation("test-fixtures/mix.lock"))
    14  	expected := []pkg.Package{
    15  		{
    16  			Name:      "castore",
    17  			Version:   "0.1.17",
    18  			Language:  pkg.Elixir,
    19  			Type:      pkg.HexPkg,
    20  			Locations: locations,
    21  			PURL:      "pkg:hex/castore@0.1.17",
    22  			Metadata: pkg.ElixirMixLockEntry{
    23  				Name:       "castore",
    24  				Version:    "0.1.17",
    25  				PkgHash:    "ba672681de4e51ed8ec1f74ed624d104c0db72742ea1a5e74edbc770c815182f",
    26  				PkgHashExt: "d9844227ed52d26e7519224525cb6868650c272d4a3d327ce3ca5570c12163f9",
    27  			},
    28  		},
    29  		{
    30  			Name:      "connection",
    31  			Version:   "1.1.0",
    32  			Language:  pkg.Elixir,
    33  			Type:      pkg.HexPkg,
    34  			Locations: locations,
    35  			PURL:      "pkg:hex/connection@1.1.0",
    36  			Metadata: pkg.ElixirMixLockEntry{
    37  				Name:       "connection",
    38  				Version:    "1.1.0",
    39  				PkgHash:    "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68",
    40  				PkgHashExt: "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c",
    41  			},
    42  		},
    43  		{
    44  			Name:      "cowboy",
    45  			Version:   "2.9.0",
    46  			Language:  pkg.Elixir,
    47  			Type:      pkg.HexPkg,
    48  			Locations: locations,
    49  			PURL:      "pkg:hex/cowboy@2.9.0",
    50  			Metadata: pkg.ElixirMixLockEntry{
    51  				Name:       "cowboy",
    52  				Version:    "2.9.0",
    53  				PkgHash:    "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452",
    54  				PkgHashExt: "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde",
    55  			},
    56  		},
    57  		{
    58  			Name:      "cowboy_telemetry",
    59  			Version:   "0.4.0",
    60  			Language:  pkg.Elixir,
    61  			Type:      pkg.HexPkg,
    62  			Locations: locations,
    63  			PURL:      "pkg:hex/cowboy_telemetry@0.4.0",
    64  			Metadata: pkg.ElixirMixLockEntry{
    65  				Name:       "cowboy_telemetry",
    66  				Version:    "0.4.0",
    67  				PkgHash:    "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c",
    68  				PkgHashExt: "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de",
    69  			},
    70  		},
    71  		{
    72  			Name:      "cowlib",
    73  			Version:   "2.11.0",
    74  			Language:  pkg.Elixir,
    75  			Type:      pkg.HexPkg,
    76  			Locations: locations,
    77  			PURL:      "pkg:hex/cowlib@2.11.0",
    78  			Metadata: pkg.ElixirMixLockEntry{
    79  				Name:       "cowlib",
    80  				Version:    "2.11.0",
    81  				PkgHash:    "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063",
    82  				PkgHashExt: "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9",
    83  			},
    84  		},
    85  		{
    86  			Name:      "db_connection",
    87  			Version:   "2.4.2",
    88  			Language:  pkg.Elixir,
    89  			Type:      pkg.HexPkg,
    90  			Locations: locations,
    91  			PURL:      "pkg:hex/db_connection@2.4.2",
    92  			Metadata: pkg.ElixirMixLockEntry{
    93  				Name:       "db_connection",
    94  				Version:    "2.4.2",
    95  				PkgHash:    "f92e79aff2375299a16bcb069a14ee8615c3414863a6fef93156aee8e86c2ff3",
    96  				PkgHashExt: "4fe53ca91b99f55ea249693a0229356a08f4d1a7931d8ffa79289b145fe83668",
    97  			},
    98  		},
    99  		{
   100  			Name:      "decimal",
   101  			Version:   "2.0.0",
   102  			Language:  pkg.Elixir,
   103  			Type:      pkg.HexPkg,
   104  			Locations: locations,
   105  			PURL:      "pkg:hex/decimal@2.0.0",
   106  			Metadata: pkg.ElixirMixLockEntry{
   107  				Name:       "decimal",
   108  				Version:    "2.0.0",
   109  				PkgHash:    "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697",
   110  				PkgHashExt: "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577",
   111  			},
   112  		},
   113  		{
   114  			Name:      "earmark_parser",
   115  			Version:   "1.4.25",
   116  			Language:  pkg.Elixir,
   117  			Type:      pkg.HexPkg,
   118  			Locations: locations,
   119  			PURL:      "pkg:hex/earmark_parser@1.4.25",
   120  			Metadata: pkg.ElixirMixLockEntry{
   121  				Name:       "earmark_parser",
   122  				Version:    "1.4.25",
   123  				PkgHash:    "2024618731c55ebfcc5439d756852ec4e85978a39d0d58593763924d9a15916f",
   124  				PkgHashExt: "56749c5e1c59447f7b7a23ddb235e4b3defe276afc220a6227237f3efe83f51e",
   125  			},
   126  		},
   127  		{
   128  			Name:      "ecto",
   129  			Version:   "3.8.1",
   130  			Language:  pkg.Elixir,
   131  			Type:      pkg.HexPkg,
   132  			Locations: locations,
   133  			PURL:      "pkg:hex/ecto@3.8.1",
   134  			Metadata: pkg.ElixirMixLockEntry{
   135  				Name:       "ecto",
   136  				Version:    "3.8.1",
   137  				PkgHash:    "35e0bd8c8eb772e14a5191a538cd079706ecb45164ea08a7523b4fc69ab70f56",
   138  				PkgHashExt: "f1b68f8d5fe3ab89e24f57c03db5b5d0aed3602077972098b3a6006a1be4b69b",
   139  			},
   140  		},
   141  		{
   142  			Name:      "ecto_sql",
   143  			Version:   "3.8.1",
   144  			Language:  pkg.Elixir,
   145  			Type:      pkg.HexPkg,
   146  			Locations: locations,
   147  			PURL:      "pkg:hex/ecto_sql@3.8.1",
   148  			Metadata: pkg.ElixirMixLockEntry{
   149  				Name:       "ecto_sql",
   150  				Version:    "3.8.1",
   151  				PkgHash:    "1acaaba32ca0551fd19e492fc7c80414e72fc1a7140fc9395aaa53c2e8629798",
   152  				PkgHashExt: "ba7fc75882edce6f2ceca047315d5db27ead773cafea47f1724e35f1e7964525",
   153  			},
   154  		},
   155  		{
   156  			Name:      "esbuild",
   157  			Version:   "0.5.0",
   158  			Language:  pkg.Elixir,
   159  			Type:      pkg.HexPkg,
   160  			Locations: locations,
   161  			PURL:      "pkg:hex/esbuild@0.5.0",
   162  			Metadata: pkg.ElixirMixLockEntry{
   163  				Name:       "esbuild",
   164  				Version:    "0.5.0",
   165  				PkgHash:    "d5bb08ff049d7880ee3609ed5c4b864bd2f46445ea40b16b4acead724fb4c4a3",
   166  				PkgHashExt: "f183a0b332d963c4cfaf585477695ea59eef9a6f2204fdd0efa00e099694ffe5",
   167  			},
   168  		},
   169  		{
   170  			Name:      "ex_doc",
   171  			Version:   "0.28.4",
   172  			Language:  pkg.Elixir,
   173  			Type:      pkg.HexPkg,
   174  			Locations: locations,
   175  			PURL:      "pkg:hex/ex_doc@0.28.4",
   176  			Metadata: pkg.ElixirMixLockEntry{
   177  				Name:       "ex_doc",
   178  				Version:    "0.28.4",
   179  				PkgHash:    "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298",
   180  				PkgHashExt: "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed",
   181  			},
   182  		},
   183  		{
   184  			Name:      "gettext",
   185  			Version:   "0.19.1",
   186  			Language:  pkg.Elixir,
   187  			Type:      pkg.HexPkg,
   188  			Locations: locations,
   189  			PURL:      "pkg:hex/gettext@0.19.1",
   190  			Metadata: pkg.ElixirMixLockEntry{
   191  				Name:       "gettext",
   192  				Version:    "0.19.1",
   193  				PkgHash:    "564953fd21f29358e68b91634799d9d26989f8d039d7512622efb3c3b1c97892",
   194  				PkgHashExt: "10c656c0912b8299adba9b061c06947511e3f109ab0d18b44a866a4498e77222",
   195  			},
   196  		},
   197  		{
   198  			Name:      "hpax",
   199  			Version:   "0.1.1",
   200  			Language:  pkg.Elixir,
   201  			Type:      pkg.HexPkg,
   202  			Locations: locations,
   203  			PURL:      "pkg:hex/hpax@0.1.1",
   204  			Metadata: pkg.ElixirMixLockEntry{
   205  				Name:       "hpax",
   206  				Version:    "0.1.1",
   207  				PkgHash:    "2396c313683ada39e98c20a75a82911592b47e5c24391363343bde74f82396ca",
   208  				PkgHashExt: "0ae7d5a0b04a8a60caf7a39fcf3ec476f35cc2cc16c05abea730d3ce6ac6c826",
   209  			},
   210  		},
   211  		{
   212  			Name:      "jason",
   213  			Version:   "1.3.0",
   214  			Language:  pkg.Elixir,
   215  			Type:      pkg.HexPkg,
   216  			Locations: locations,
   217  			PURL:      "pkg:hex/jason@1.3.0",
   218  			Metadata: pkg.ElixirMixLockEntry{
   219  				Name:       "jason",
   220  				Version:    "1.3.0",
   221  				PkgHash:    "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946",
   222  				PkgHashExt: "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac",
   223  			},
   224  		},
   225  	}
   226  
   227  	fixture := "test-fixtures/mix.lock"
   228  
   229  	// TODO: relationships are not under test
   230  	var expectedRelationships []artifact.Relationship
   231  
   232  	pkgtest.TestFileParser(t, fixture, parseMixLock, expected, expectedRelationships)
   233  }