@@ -54,13 +54,16 @@ public interface RekorResponse {
54
54
* @return an immutable {@link RekorResponse} instance
55
55
* @throws RekorParseException if the rawResponse doesn't parse directly to a single rekor entry
56
56
*/
57
- public static RekorResponse newRekorResponse (URI entryLocation , String rawResponse )
57
+ static RekorResponse newRekorResponse (URI entryLocation , String rawResponse )
58
58
throws RekorParseException {
59
59
var type = new TypeToken <Map <String , RekorEntry >>() {}.getType ();
60
60
Map <String , RekorEntry > entryMap ;
61
61
try {
62
62
entryMap = GSON .get ().fromJson (rawResponse , type );
63
- } catch (JsonSyntaxException | NullPointerException | StringIndexOutOfBoundsException ex ) {
63
+ } catch (JsonSyntaxException
64
+ | NullPointerException
65
+ | NumberFormatException
66
+ | StringIndexOutOfBoundsException ex ) {
64
67
throw new RekorParseException ("Rekor entry json could not be parsed: " + rawResponse , ex );
65
68
}
66
69
if (entryMap == null ) {
@@ -71,6 +74,10 @@ public static RekorResponse newRekorResponse(URI entryLocation, String rawRespon
71
74
"Expecting a single rekor entry in response but found: " + entryMap .size ());
72
75
}
73
76
var entry = entryMap .entrySet ().iterator ().next ();
77
+ if (entry == null || entry .getKey () == null || entry .getValue () == null ) {
78
+ throw new RekorParseException (
79
+ "Expecting single rekor entry but found an invalid entry: " + rawResponse );
80
+ }
74
81
return ImmutableRekorResponse .builder ()
75
82
.entryLocation (entryLocation )
76
83
.raw (rawResponse )
0 commit comments