Permalink
Browse files

Merge pull request #17 from michaelmccaskill/WEBSITE-277

[FIX WEBSITE-277] - Fix mappings, ingestion
  • Loading branch information...
2 parents bea7f9b + 1b61d74 commit 98e239fe6efea7af91e8bd8bb65b63cd48743394 @michaelmccaskill michaelmccaskill committed on GitHub Jan 25, 2017
@@ -220,13 +220,22 @@ private Plugin parsePlugin(JSONObject json, Path statisticsPath, Map<String, Str
final List<SecurityWarning> warnings = new ArrayList<>();
for (JSONObject warningJson : warningsMap.get(plugin.getName())) {
final List<SecurityWarningVersion> versions = new ArrayList<>();
- StreamSupport.stream(warningJson.getJSONArray("versions").spliterator(), false).forEach((obj) -> {
+ final boolean applyToCurrentVersion = StreamSupport.stream(warningJson.getJSONArray("versions").spliterator(), false).map((obj) -> {
final JSONObject versionJson = (JSONObject)obj;
final Pattern pattern = Pattern.compile(versionJson.getString("pattern"));
- final boolean applyToCurrentVersion = pattern.matcher(plugin.getVersion()).matches();
- versions.add(new SecurityWarningVersion(versionJson.getString("lastVersion"), applyToCurrentVersion));
- });
- warnings.add(new SecurityWarning(warningJson.getString("id"), warningJson.getString("message"), warningJson.getString("url"), versions));
+ versions.add(new SecurityWarningVersion(
+ versionJson.optString("firstVersion", null),
+ versionJson.optString("lastVersion", null))
+ );
+ return pattern.matcher(plugin.getVersion()).matches();
+ }).reduce(false, (accum, next) -> accum || next);
+ warnings.add(new SecurityWarning(
+ warningJson.getString("id"),
+ warningJson.getString("message"),
+ warningJson.getString("url"),
+ versions,
+ applyToCurrentVersion)
+ );
}
plugin.setSecurityWarnings(warnings);
}
@@ -20,14 +20,18 @@
@JsonProperty("warnings")
private List<SecurityWarningVersion> versions;
+ @JsonProperty("applyToCurrentVersion")
+ private boolean applyToCurrentVersion;
+
public SecurityWarning() {
}
- public SecurityWarning(String id, String message, String url, List<SecurityWarningVersion> versions) {
+ public SecurityWarning(String id, String message, String url, List<SecurityWarningVersion> versions, boolean applyToCurrentVersion) {
this.id = id;
this.message = message;
this.url = url;
this.versions = versions;
+ this.applyToCurrentVersion = applyToCurrentVersion;
}
public String getId() {
@@ -61,4 +65,13 @@ public void setUrl(String url) {
public void setVersions(List<SecurityWarningVersion> versions) {
this.versions = versions;
}
+
+ public boolean isApplyToCurrentVersion() {
+ return applyToCurrentVersion;
+ }
+
+ public void setApplyToCurrentVersion(boolean applyToCurrentVersion) {
+ this.applyToCurrentVersion = applyToCurrentVersion;
+ }
+
}
@@ -6,18 +6,26 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class SecurityWarningVersion {
+ @JsonProperty("firstVersion")
+ private String firstVersion;
+
@JsonProperty("lastVersion")
private String lastVersion;
- @JsonProperty("applyToCurrentVersion")
- private boolean applyToCurrentVersion;
-
public SecurityWarningVersion() {
}
- public SecurityWarningVersion(String lastVersion, boolean applyToCurrentVersion) {
+ public SecurityWarningVersion(String firstVersion, String lastVersion) {
+ this.firstVersion = firstVersion;
this.lastVersion = lastVersion;
- this.applyToCurrentVersion = applyToCurrentVersion;
+ }
+
+ public String getFirstVersion() {
+ return firstVersion;
+ }
+
+ public void setFirstVersion(String firstVersion) {
+ this.firstVersion = firstVersion;
}
public String getLastVersion() {
@@ -28,11 +36,5 @@ public void setLastVersion(String lastVersion) {
this.lastVersion = lastVersion;
}
- public boolean isApplyToCurrentVersion() {
- return applyToCurrentVersion;
- }
- public void setApplyToCurrentVersion(boolean applyToCurrentVersion) {
- this.applyToCurrentVersion = applyToCurrentVersion;
- }
}
@@ -118,6 +118,38 @@
}
}
},
+ "securityWarnings": {
+ "type" : "nested",
+ "properties" : {
+ "applyToCurrentVersion": {
+ "type": "boolean"
+ },
+ "id": {
+ "type" : "string",
+ "index" : "not_analyzed"
+ },
+ "message": {
+ "type" : "string"
+ },
+ "url": {
+ "type" : "string",
+ "index" : "not_analyzed"
+ },
+ "warnings": {
+ "type" : "nested",
+ "properties" : {
+ "firstVersion": {
+ "type" : "string",
+ "index" : "not_analyzed"
+ },
+ "lastVersion": {
+ "type" : "string",
+ "index" : "not_analyzed"
+ }
+ }
+ }
+ }
+ },
"sha1" : {
"type" : "string",
"index" : "not_analyzed"
Oops, something went wrong.

0 comments on commit 98e239f

Please sign in to comment.