make the extractor not crash on invalid "package.json" files

This commit is contained in:
Erik Krogh Kristensen
2020-08-24 12:42:08 +02:00
parent 1b655f9046
commit d633410e3c
8 changed files with 95 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.Optional;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.semmle.js.extractor.ExtractorConfig.Platform;
import com.semmle.js.extractor.ExtractorConfig.SourceType;
@@ -128,7 +129,7 @@ public class ScriptExtractor implements IExtractor {
String result = new Gson().fromJson(reader, PackageJSON.class).type;
packageTypeCache.put(folder, Optional.ofNullable(result));
return result;
} catch (IOException e) {
} catch (IOException | JsonSyntaxException e) {
return null;
}
}