public static List<PhpIniIssue> checkRequiredBoolean(PhpIniFile phpIniFile, String directiveName, PhpIniBoolean requiredValue, String directiveMessage, @Nullable String fileMessage) { List<Directive> directives = phpIniFile.directivesForName(directiveName); List<PhpIniIssue> issues = new ArrayList<>(); for (Directive directive : directives) { if (!requiredValue.matchesValue(directive)) { issues.add(newIssue(directiveMessage).line(directive.name().line())); } } if (fileMessage != null && directives.isEmpty()) { issues.add(newIssue(fileMessage)); } return issues; }
public static List<PhpIniIssue> checkRequiredBoolean(PhpIniFile phpIniFile, String directiveName, PhpIniBoolean requiredValue, String directiveMessage, @Nullable String fileMessage) { List<Directive> directives = phpIniFile.directivesForName(directiveName); List<PhpIniIssue> issues = new ArrayList<>(); for (Directive directive : directives) { if (!requiredValue.matchesValue(directive)) { issues.add(newIssue(directiveMessage).line(directive.name().line())); } } if (fileMessage != null && directives.isEmpty()) { issues.add(newIssue(fileMessage)); } return issues; }
@Override public List<PhpIniIssue> analyze(PhpIniFile phpIniFile) { List<PhpIniIssue> issues = new ArrayList<>(); List<Directive> directives = phpIniFile.directivesForName("open_basedir"); if (directives.isEmpty()) { issues.add(newIssue(FILE_MESSAGE)); } for (Directive directive : directives) { String value = directive.value().text(); if (value.startsWith("\"")) { value = value.substring(1); } if (value.endsWith("\"")) { value = value.substring(0, value.length() - 1); } for (String path : value.split(":|;")) { if (".".equals(path) || "/".equals(path)) { String message = String.format(DIRECTIVE_MESSAGE, path); int line = directive.name().line(); issues.add(newIssue(message).line(line)); break; } } } return issues; }
@Override public List<PhpIniIssue> analyze(PhpIniFile phpIniFile) { List<PhpIniIssue> issues = new ArrayList<>(); List<Directive> directives = phpIniFile.directivesForName("open_basedir"); if (directives.isEmpty()) { issues.add(newIssue(FILE_MESSAGE)); } for (Directive directive : directives) { String value = directive.value().text(); if (value.startsWith("\"")) { value = value.substring(1); } if (value.endsWith("\"")) { value = value.substring(0, value.length() - 1); } for (String path : value.split(":|;")) { if (".".equals(path) || "/".equals(path)) { String message = String.format(DIRECTIVE_MESSAGE, path); int line = directive.name().line(); issues.add(newIssue(message).line(line)); break; } } } return issues; }
@Override public List<PhpIniIssue> analyze(PhpIniFile phpIniFile) { List<PhpIniIssue> issues = new ArrayList<>(); for (Directive directive : phpIniFile.directivesForName("session.cookie_lifetime")) { String value = directive.value().text(); if (!"0".equals(value) && !"\"0\"".equals(value)) { issues.add(BasePhpIniIssue.newIssue(PHP_INI_MESSAGE).line(directive.name().line())); } } return issues; }
@Override public List<PhpIniIssue> analyze(PhpIniFile phpIniFile) { return phpIniFile.directivesForName("session.cookie_domain").stream() .filter(d -> isFirstLevelDomain(d.value().text())) .map(d -> BasePhpIniIssue.newIssue(MESSAGE).line(d.name().line())) .collect(Collectors.toList()); }
@Override public List<PhpIniIssue> analyze(PhpIniFile phpIniFile) { List<PhpIniIssue> issues = new ArrayList<>(); for (Directive directive : phpIniFile.directivesForName("session.cookie_lifetime")) { String value = directive.value().text(); if (!"0".equals(value) && !"\"0\"".equals(value)) { issues.add(BasePhpIniIssue.newIssue(PHP_INI_MESSAGE).line(directive.name().line())); } } return issues; }
@Override public List<PhpIniIssue> analyze(PhpIniFile phpIniFile) { return phpIniFile.directivesForName("session.cookie_domain").stream() .filter(d -> isFirstLevelDomain(d.value().text())) .map(d -> BasePhpIniIssue.newIssue(MESSAGE).line(d.name().line())) .collect(Collectors.toList()); }
@Test public void new_issue() throws Exception { PhpIniIssue issue = newIssue("message1").line(42); assertThat(issue.message()).isEqualTo("message1"); assertThat(issue.line()).isEqualTo(42); }