File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1919import java .util .regex .Pattern ;
2020
2121import com .google .gson .Gson ;
22+ import com .google .gson .JsonParseException ;
23+
2224import com .semmle .js .dependencies .packument .Packument ;
2325
2426import org .apache .commons .compress .archivers .tar .TarArchiveEntry ;
@@ -84,7 +86,13 @@ public Packument getPackument(String packageName) throws IOException {
8486 }
8587 System .out .println ("Fetching package metadata for " + packageName );
8688 try (Reader reader = new BufferedReader (new InputStreamReader (fetch ("https://registry.npmjs.org/" + packageName )))) {
87- return new Gson ().fromJson (reader , Packument .class );
89+ Packument packument = new Gson ().fromJson (reader , Packument .class );
90+ if (packument == null ) {
91+ throw new IOException ("Malformed packument for " + packageName );
92+ }
93+ return packument ;
94+ } catch (JsonParseException ex ) {
95+ throw new IOException ("Malformed packument for " + packageName , ex );
8896 }
8997 }
9098
You can’t perform that action at this time.
0 commit comments