|
| 1 | +package com.logpresso.scanner; |
| 2 | + |
| 3 | +public class DetectResult { |
| 4 | + private boolean vulnerable = false; |
| 5 | + private boolean mitigated = false; |
| 6 | + private boolean potentiallyVulnerableLog4j2 = false; |
| 7 | + private boolean potentiallyVulnerableLog4j1 = false; |
| 8 | + private boolean potentiallyVulnerableLogback = false; |
| 9 | + private boolean nestedJar = false; |
| 10 | + |
| 11 | + public void merge(DetectResult result) { |
| 12 | + vulnerable |= result.isVulnerable(); |
| 13 | + mitigated |= result.isMitigated(); |
| 14 | + potentiallyVulnerableLog4j1 |= result.isPotentiallyVulnerableLog4j1(); |
| 15 | + potentiallyVulnerableLog4j2 |= result.isPotentiallyVulnerableLog4j2(); |
| 16 | + potentiallyVulnerableLogback |= result.isPotentiallyVulnerableLogback(); |
| 17 | + } |
| 18 | + |
| 19 | + public boolean isVulnerable() { |
| 20 | + return vulnerable; |
| 21 | + } |
| 22 | + |
| 23 | + public void setVulnerable() { |
| 24 | + this.vulnerable = true; |
| 25 | + } |
| 26 | + |
| 27 | + public boolean isMitigated() { |
| 28 | + return mitigated; |
| 29 | + } |
| 30 | + |
| 31 | + public void setMitigated() { |
| 32 | + this.mitigated = true; |
| 33 | + } |
| 34 | + |
| 35 | + public boolean isPotentiallyVulnerableLog4j2() { |
| 36 | + return potentiallyVulnerableLog4j2; |
| 37 | + } |
| 38 | + |
| 39 | + public void setPotentiallyVulnerableLog4j2() { |
| 40 | + this.potentiallyVulnerableLog4j2 = true; |
| 41 | + } |
| 42 | + |
| 43 | + public boolean isPotentiallyVulnerableLog4j1() { |
| 44 | + return potentiallyVulnerableLog4j1; |
| 45 | + } |
| 46 | + |
| 47 | + public void setPotentiallyVulnerableLog4j1() { |
| 48 | + this.potentiallyVulnerableLog4j1 = true; |
| 49 | + } |
| 50 | + |
| 51 | + public boolean isPotentiallyVulnerableLogback() { |
| 52 | + return potentiallyVulnerableLogback; |
| 53 | + } |
| 54 | + |
| 55 | + public void setPotentiallyVulnerableLogback() { |
| 56 | + this.potentiallyVulnerableLogback = true; |
| 57 | + } |
| 58 | + |
| 59 | + public boolean hasNestedJar() { |
| 60 | + return nestedJar; |
| 61 | + } |
| 62 | + |
| 63 | + public void setNestedJar(boolean nestedJar) { |
| 64 | + this.nestedJar |= nestedJar; |
| 65 | + } |
| 66 | + |
| 67 | + public Status getStatus() { |
| 68 | + if (vulnerable) |
| 69 | + return Status.VULNERABLE; |
| 70 | + else if (mitigated) |
| 71 | + return Status.MITIGATED; |
| 72 | + else if (isPotentiallyVulnerable()) |
| 73 | + return Status.POTENTIALLY_VULNERABLE; |
| 74 | + return Status.NOT_VULNERABLE; |
| 75 | + } |
| 76 | + |
| 77 | + public boolean isPotentiallyVulnerable() { |
| 78 | + return potentiallyVulnerableLog4j2 || potentiallyVulnerableLog4j1 || potentiallyVulnerableLogback; |
| 79 | + } |
| 80 | + |
| 81 | + public boolean isFixRequired() { |
| 82 | + // Don't touch potentially vulnerable log4j2 |
| 83 | + return vulnerable || potentiallyVulnerableLog4j1 || potentiallyVulnerableLogback; |
| 84 | + } |
| 85 | +} |
0 commit comments