@@ -1638,7 +1638,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
1638
1638
}
1639
1639
1640
1640
/**
1641
- * Given a lock file this method would return an Object with the identiy as the key and parsed name and value
1641
+ * Given a lock file this method would return an Object with the identity as the key and parsed name and value
1642
1642
* eg: "@actions/core@^1.2.6", "@actions/core@^1.6.0":
1643
1643
* version "1.6.0"
1644
1644
* would result in two entries
@@ -1650,7 +1650,7 @@ export function yarnLockToIdentMap(lockData) {
1650
1650
let currentIdents = [ ] ;
1651
1651
lockData . split ( "\n" ) . forEach ( ( l ) => {
1652
1652
l = l . replace ( "\r" , "" ) ;
1653
- if ( l === "\n" || l . startsWith ( "#" ) ) {
1653
+ if ( l === "\n" || ! l . length || l . startsWith ( "#" ) ) {
1654
1654
return ;
1655
1655
}
1656
1656
// "@actions/core@^1.2.6", "@actions/core@^1.6.0":
@@ -1707,14 +1707,22 @@ export function yarnLockToIdentMap(lockData) {
1707
1707
function _parseYarnLine ( l ) {
1708
1708
let name = "" ;
1709
1709
let group = "" ;
1710
- const prefixAtSymbol = l . startsWith ( "@" ) ;
1710
+ let prefixAtSymbol = l . startsWith ( "@" ) ;
1711
1711
const tmpA = l . split ( "@" ) ;
1712
1712
// ignore possible leading empty strings
1713
1713
if ( tmpA [ 0 ] === "" ) {
1714
1714
tmpA . shift ( ) ;
1715
1715
}
1716
+ let fullName ;
1716
1717
if ( tmpA . length >= 2 ) {
1717
- const fullName = tmpA [ 0 ] ;
1718
+ if ( tmpA . length === 4 ) {
1719
+ if ( tmpA [ 1 ] === "npm:" ) {
1720
+ prefixAtSymbol = true ;
1721
+ }
1722
+ fullName = tmpA [ 2 ] ;
1723
+ } else {
1724
+ fullName = tmpA [ 0 ] ;
1725
+ }
1718
1726
if ( fullName . indexOf ( "/" ) > - 1 ) {
1719
1727
const parts = fullName . split ( "/" ) ;
1720
1728
group = ( prefixAtSymbol ? "@" : "" ) + parts [ 0 ] ;
@@ -1891,16 +1899,26 @@ export async function parseYarnLock(yarnLockFile) {
1891
1899
if ( dgroupname . endsWith ( ":" ) ) {
1892
1900
dgroupname = dgroupname . substring ( 0 , dgroupname . length - 1 ) ;
1893
1901
}
1894
- let range = tmpA [ 1 ] . replace ( / [ " ' ] / g, "" ) ;
1902
+ let dgroupnameToUse = dgroupname ;
1903
+ const range = tmpA [ 1 ] . replace ( / [ " ' ] / g, "" ) ;
1904
+ let versionRange = range ;
1895
1905
// Deal with range with npm: prefix such as npm:string-width@^4.2.0, npm:@types/ioredis@^4.28.10
1896
1906
if ( range . startsWith ( "npm:" ) ) {
1897
- range = range . split ( "@" ) . splice ( - 1 ) [ 0 ] ;
1907
+ versionRange = range . split ( "@" ) . splice ( - 1 ) [ 0 ] ;
1908
+ dgroupnameToUse = range
1909
+ . replace ( "npm:" , "" )
1910
+ . replace ( `@${ versionRange } ` , "" ) ;
1898
1911
}
1899
- const resolvedVersion = identMap [ `${ dgroupname } |${ range } ` ] ;
1912
+ const resolvedVersion =
1913
+ identMap [ `${ dgroupname } |${ versionRange } ` ] ||
1914
+ identMap [ `${ dgroupnameToUse } |${ versionRange } ` ] ;
1915
+ // Handle case where the dependency name is really an alias.
1916
+ // Eg: legacy-swc-helpers "npm:@swc/helpers@=0.4.14". Here the dgroupname=@swc/helpers
1917
+
1900
1918
const depPurlString = new PackageURL (
1901
1919
"npm" ,
1902
1920
null ,
1903
- dgroupname ,
1921
+ dgroupnameToUse ,
1904
1922
resolvedVersion ,
1905
1923
null ,
1906
1924
null ,
@@ -14183,6 +14201,9 @@ export function addEvidenceForDotnet(pkgList, slicesFile) {
14183
14201
}
14184
14202
const slicesData = JSON . parse ( readFileSync ( slicesFile , "utf-8" ) ) ;
14185
14203
if ( slicesData && Object . keys ( slicesData ) ) {
14204
+ thoughtLog (
14205
+ "Let's thoroughly inspect the dependency slice to identify where and how the components are used." ,
14206
+ ) ;
14186
14207
if ( slicesData . Dependencies ) {
14187
14208
for ( const adep of slicesData . Dependencies ) {
14188
14209
// Case 1: Dependencies slice has the .dll file
@@ -14274,6 +14295,10 @@ export function addEvidenceForDotnet(pkgList, slicesFile) {
14274
14295
} ) ;
14275
14296
}
14276
14297
}
14298
+ } else if ( slicesData ?. Dependencies || slicesData ?. MethodCalls ) {
14299
+ thoughtLog (
14300
+ "I didn't find any occurrence evidence or detailed imported modules, even though there is good dependency slice data from dosai. This is surprising." ,
14301
+ ) ;
14277
14302
}
14278
14303
return pkgList ;
14279
14304
}
0 commit comments