diff --git a/.gitignore b/.gitignore index d59b54a..6ff13dd 100644 --- a/.gitignore +++ b/.gitignore @@ -49,10 +49,12 @@ fabric.properties # IntelliJ project files .idea *.iml -out + gen### Gradle template .gradle -/build/ +build +backup +testdata # Ignore Gradle GUI config gradle-app.setting diff --git a/build.gradle b/build.gradle index 76e6c9f..bf6fbba 100755 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ apply plugin: 'java' apply plugin: 'groovy' apply plugin: 'distribution' +//apply plugin: 'antlr' def getVersionName = { -> try { @@ -40,19 +41,26 @@ repositories { } dependencies { - compile 'org.codehaus.groovy:groovy:2.4.8' - compile 'org.codehaus.groovy:groovy-xml:2.4.8' - compile 'org.codehaus.groovy:groovy-json:2.4.8' - compile 'org.codehaus.groovy:groovy-swing:2.4.8' - compile 'net.java.dev.glazedlists:glazedlists_java15:1.9.1' - compile 'com.miglayout:miglayout-swing:5.0' - compile 'org.slf4j:slf4j-api:1.7.22' + compile 'org.antlr:antlr4-runtime:4.7' + + compile 'org.codehaus.groovy:groovy-all:2.4.8' +// compile 'org.codehaus.groovy:groovy-xml:2.4.8' +// compile 'org.codehaus.groovy:groovy-json:2.4.8' + compile 'org.apache.commons:commons-pool2:2.4.2' + compile 'org.groovyfx:groovyfx:8.0.0' +// compile group: 'org.apache.commons', name: 'commons-pool2', version: '2.4.2' +// compile 'org.codehaus.groovy:groovy-swing:2.4.8' +// compile 'net.java.dev.glazedlists:glazedlists_java15:1.9.1' +// compile 'com.miglayout:miglayout-swing:5.0' +// compile 'org.slf4j:slf4j-api:1.7.22' // https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 - compile group: 'org.apache.commons', name: 'commons-pool2', version: '2.4.2' + +// https://mvnrepository.com/artifact/org.json/json + compile group: 'org.json', name: 'json', version: '20170516' testCompile 'junit:junit:4.12' - testCompile 'org.assertj:assertj-swing-junit:3.5.0' +// testCompile 'org.assertj:assertj-swing-junit:3.5.0' } jar { @@ -60,8 +68,10 @@ jar { from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } manifest { - attributes 'Main-Class':' net.vdbaan.issuefinder.App', + attributes 'Main-Class':' net.vdbaan.issuefinder.Runner', +// 'Class-Path':'.', 'version':project.version + } } diff --git a/src/main/antlr/Predicate.g4 b/src/main/antlr/Predicate.g4 new file mode 100644 index 0000000..b792b95 --- /dev/null +++ b/src/main/antlr/Predicate.g4 @@ -0,0 +1,113 @@ +grammar Predicate; + +//IP == "127.0.0.1" +//SCANNER ~= 'nmap' +//SERVICE LIKE 'http' +//PORT LIKE "443" +//EXPLOITABLE +//(SERVICE LIKE 'SMB') && !EXPLOITABLE +// (PORT LIKE "443") || (SERVICE LIKE "http") +// ((IP == "127.0.0.1") && (!EXPLOITABLE)) || ((PORT LIKE "443") && (SERVICE LIKE "http")) +// Predicate(Predicate(IP,==,"127.0.0.1).and(Predicate.not(EXPLOITABLE)).or(Predicate(PORT,LIKE,"443").and(Predicate(SERVICE,LIKE,'http'))) + +@header { +package net.vdbaan.issuefinder.parser; +} + +expr: expr AND expr # andExpr + | expr OR expr # orExpr + | LPAREN expr RPAREN # enclosedExpr + | NOT expr # notExpr + | column operator STRING # assign + | column rangeOperator RANGE # range + | column groupOperator GROUP # group + | NOT column # notColumn + ; + +LPAREN: '('; +RPAREN: ')'; +AND : '&&' | 'AND'; +OR : '||' | 'OR'; +NOT : '!'; + + //SCANNER("SCANNER"),IP("IP"),PORT("PORT"),SERVICE("SERVICE"),RISK("RISK"),EXPLOITABLE("EXPLOITABLE"),DESCRIPTION("DESCRIPTION") +column + : SCANNER + | IP + | PORT + | SERVICE + | RISK + | EXPLOITABLE + | DESCRIPTION + | PLUGIN + ; + +groupOperator: IN; +rangeOperator: BETWEEN; + +operator + : '==' + | '!=' + | '<' + | '<=' + | '>' + | '=>' + | '~=' + | LIKE + ; + +IP: I P; +SCANNER: S C A N N E R; +PORT: P O R T; +SERVICE: S E R V I C E; +RISK: R I S K; +EXPLOITABLE: E X P L O I T A B L E; +DESCRIPTION: D E S C R I P T I O N; +PLUGIN: P L U G I N; + +IN: I N; +LIKE: L I K E; +BETWEEN: B E T W E E N; + +GROUP: '[' STRING (',' STRING)+ ']'; +RANGE: LPAREN STRING ',' STRING RPAREN; +STRING + : DQUOTE ~["]+? DQUOTE + | SQUOTE ~[']+? SQUOTE + | CHAR + ; + +fragment A: [aA]; +fragment B: [bB]; +fragment C: [cC]; +fragment D: [dD]; +fragment E: [eE]; +fragment F: [fF]; +fragment G: [gG]; +fragment H: [hH]; +fragment I: [iI]; +fragment J: [jJ]; +fragment K: [kK]; +fragment L: [lL]; +fragment M: [mM]; +fragment N: [nN]; +fragment O: [oO]; +fragment P: [pP]; +fragment Q: [qQ]; +fragment R: [rR]; +fragment S: [sS]; +fragment T: [tT]; +fragment U: [uU]; +fragment V: [vV]; +fragment W: [wW]; +fragment X: [xX]; +fragment Y: [yY]; +fragment Z: [zZ]; + + +SQUOTE: '\'' -> skip; +DQUOTE: '"' -> skip; +//CHAR : ~[ \t\r\n"']+ ; // // match any chars except space tab, newline, double and single quote + +CHAR: [a-zA-Z/\\.0-9:;]+; +WS : [ \t\n\r]+ -> skip ; // skip spaces, tabs, newlines, \r (Windows) \ No newline at end of file diff --git a/src/main/groovy/net/vdbaan/issuefinder/MainApp.groovy b/src/main/groovy/net/vdbaan/issuefinder/MainApp.groovy new file mode 100644 index 0000000..583ff7f --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/MainApp.groovy @@ -0,0 +1,89 @@ +package net.vdbaan.issuefinder + +import javafx.collections.FXCollections +import javafx.collections.ObservableList +import javafx.fxml.FXMLLoader +import javafx.scene.Parent +import javafx.scene.Scene +import javafx.scene.control.Label +import javafx.stage.Modality +import javafx.stage.Stage +import javafx.stage.StageStyle +import net.vdbaan.issuefinder.controller.DialogController +import net.vdbaan.issuefinder.controller.EditorController +import net.vdbaan.issuefinder.controller.FXMLController +import net.vdbaan.issuefinder.controller.ProgressController +import net.vdbaan.issuefinder.model.Finding + + +import static groovyx.javafx.GroovyFX.start + +class MainApp { + Stage primaryStage + private ObservableList masterData = FXCollections.observableArrayList() + + def run(String... args) { + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/layout.fxml")) + start { + primaryStage = stage(title: 'Issue Finder', width: 1200, height: 500, visible: true, maximized: true) { + def mainScene = scene() { + } + mainScene.root = fxmlLoader.load() + } + FXMLController controller = fxmlLoader.getController() + controller.setMasterData(masterData) + controller.setup(this) +// controller.openFiles(args.collect { new File(it) }) + } + } + + def showAbout() { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/about.fxml")) + Parent root = loader.load() + Stage dialog = new Stage() + dialog.initOwner(primaryStage) + Scene scene = new Scene(root) + dialog.initStyle(StageStyle.UNDECORATED) + dialog.setScene(scene) + DialogController controller = loader.getController() + controller.dialogPane = dialog + dialog.showAndWait() + } + + void showProgressDialog(List files, Label statusLabel) { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/progress.fxml")) + Parent root = loader.load() + Stage dialog = new Stage() + dialog.initOwner(primaryStage) + Scene scene = new Scene(root) + dialog.initStyle(StageStyle.UNDECORATED) + dialog.initModality(Modality.APPLICATION_MODAL) + dialog.setScene(scene) + ProgressController controller = loader.getController() + controller.dialogPane = dialog + controller.statusLabel = statusLabel + controller.fileList = files + controller.masterData = masterData + controller.process() + dialog.showAndWait() + } + + void showEditor(Finding finding) { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/editor.fxml")) + Parent root = loader.load() + Stage dialog = new Stage() + dialog.initOwner(primaryStage) + Scene scene = new Scene(root) + dialog.initStyle(StageStyle.UNDECORATED) + dialog.initModality(Modality.APPLICATION_MODAL) + dialog.setScene(scene) + EditorController controller = loader.getController() + controller.dialogPane = dialog + controller.masterData = masterData + controller.finding = finding + controller.setup() + dialog.showAndWait() + } + + +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/Runner.groovy b/src/main/groovy/net/vdbaan/issuefinder/Runner.groovy new file mode 100644 index 0000000..8e1c359 --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/Runner.groovy @@ -0,0 +1,20 @@ +package net.vdbaan.issuefinder + +class Runner { + static void main(String... args) { + testJavaFX() + MainApp app = new MainApp() + app.run(args) + } + + static void testJavaFX() { + try { + Class.forName('javafx.stage.Stage') + } catch(ClassNotFoundException e) { + System.err.println 'JavaFX8 Missing' + System.err.println 'Please install JavaFX, for example:' + System.err.println '- sudo apt-get install openjfx' + System.exit(1) + } + } +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/controller/DialogController.groovy b/src/main/groovy/net/vdbaan/issuefinder/controller/DialogController.groovy new file mode 100644 index 0000000..5ed3809 --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/controller/DialogController.groovy @@ -0,0 +1,32 @@ +package net.vdbaan.issuefinder.controller + +import javafx.fxml.FXML +import javafx.fxml.Initializable +import javafx.scene.control.Label +import javafx.stage.Stage + +import java.util.jar.Manifest + + +class DialogController implements Initializable { + + Stage dialogPane + + @FXML + Label version + + @Override + void initialize(URL url, ResourceBundle rb) { + def vers + getClass().classLoader.getResources('META-INF/MANIFEST.MF').each { uri -> + uri.openStream().withStream { is -> + def attributes = new Manifest(is).mainAttributes + vers = attributes.getValue('version') + } + } + version.text = (vers == null)?'Version: DEV':'Version: '+vers + } + def closeAction() { + dialogPane.hide() + } +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/controller/EditorController.groovy b/src/main/groovy/net/vdbaan/issuefinder/controller/EditorController.groovy new file mode 100644 index 0000000..724b1e6 --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/controller/EditorController.groovy @@ -0,0 +1,51 @@ +package net.vdbaan.issuefinder.controller + +import javafx.collections.ObservableList +import javafx.fxml.FXML +import javafx.scene.control.* +import javafx.stage.Stage +import net.vdbaan.issuefinder.model.Finding + + +class EditorController { + @FXML TextField editScanner + @FXML TextField editHostname + @FXML TextField editIp + @FXML TextField editPort + @FXML TextField editService + @FXML TextField editPlugin + @FXML ChoiceBox editRisk + + Stage dialogPane + ObservableList masterData + Finding finding + + def setup() { + editRisk.items.addAll(Finding.Severity.values()) + editScanner.setText(finding.scanner) + editHostname.setText(finding.hostName) + editIp.setText(finding.ip) + editPort.setText(finding.port) + editService.setText(finding.service) + editPlugin.setText(finding.plugin) + editRisk.setValue(finding.severity) + } + + boolean okClicked = false + + def doOk() { + finding.scanner = editScanner.text + finding.hostName = editHostname.text + finding.ip = editIp.text + finding.port = editPort.text + finding.service = editService.text + finding.plugin = editPlugin.text + finding.severity = editRisk.getValue() + okClicked = true + dialogPane.hide() + } + + def doCancel() { + dialogPane.hide() + } +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/controller/FXMLController.groovy b/src/main/groovy/net/vdbaan/issuefinder/controller/FXMLController.groovy new file mode 100644 index 0000000..62f5304 --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/controller/FXMLController.groovy @@ -0,0 +1,231 @@ +package net.vdbaan.issuefinder.controller + +import javafx.beans.value.ChangeListener +import javafx.beans.value.ObservableValue +import javafx.collections.ListChangeListener +import javafx.collections.ObservableList +import javafx.collections.transformation.FilteredList +import javafx.collections.transformation.SortedList + +/** + * Created by Steven on 01/09/2017. + */ +import javafx.fxml.FXML +import javafx.fxml.Initializable +import javafx.scene.control.* +import javafx.scene.web.WebView +import net.vdbaan.issuefinder.MainApp +import net.vdbaan.issuefinder.filechooser.RetentionFileChooser +import net.vdbaan.issuefinder.filter.FindingPredicate +import net.vdbaan.issuefinder.model.Finding +import net.vdbaan.issuefinder.filter.FindingPredicateParser +import net.vdbaan.issuefinder.filter.FindingPredicateParserRuntimeException + +import java.awt.Toolkit +import java.awt.datatransfer.Clipboard +import java.awt.datatransfer.StringSelection + +class FXMLController implements Initializable { + MainApp mainApp + + @FXML + Label statusLabel + @FXML + Label rowInfoLabel + @FXML + Label ipInfoLabel + @FXML + ComboBox filterText + @FXML + TableView mainTable + @FXML + WebView textArea + FilteredList filteredData + + FindingPredicateParser findingPredicateParser = new FindingPredicateParser() + + ObservableList masterData + + @Override + void initialize(URL url, ResourceBundle rb) { + statusLabel.text = 'Application started' + rowInfoLabel.text = '0 Findings' + ipInfoLabel.text = '0 unique IPs' + + filterText.items.addAll(['IP == "127.0.0.1"', 'SCANNER == \'nmap\'', 'SERVICE LIKE \'http\'', 'PORT LIKE 443', '!EXPLOITABLE', '(SERVICE LIKE \'SMB\') && EXPLOITABLE']) + } + + def setMasterData(ObservableList masterData) { + this.masterData = masterData + } + + def setup(MainApp mainApp) { + this.mainApp = mainApp + + String css = getClass().getResource('/style.css') + mainTable.getScene().getStylesheets().add(css) + + // 1. Wrap the ObservableList in a FilteredList (initially display all data). + filteredData = new FilteredList<>(masterData, { f -> true }) + + // 2. Set the filter Predicate whenever the filter changes. + + // 3. Wrap the FilteredList in a SortedList. + SortedList sortedData = new SortedList<>(filteredData) + + // 4. Bind the SortedList comparator to the TableView comparator. + // Otherwise, sorting the TableView would have no effect. + sortedData.comparatorProperty().bind(mainTable.comparatorProperty()) + + // 5. Add sorted (and filtered) data to the table. + mainTable.setItems(sortedData) + + mainTable.getSelectionModel().selectedItemProperty().addListener({ + ObservableValue observable, Finding oldValue, Finding newValue -> + if (newValue != null) { + textArea.getEngine().loadContent(newValue.htmlDescription()) + } + } as ChangeListener) + + + filteredData.addListener({ ListChangeListener.Change c -> + rowInfoLabel.text = String.format('%6d Findings', filteredData.size()) + HashSet ips = new HashSet<>() + filteredData.each { ips << it.ip } + ipInfoLabel.text = String.format('%6d unique IPs', ips.size()) + } as ListChangeListener) + + filterText.valueProperty().addListener({ obs, oldValue, newValue -> + filterTable() + } as ChangeListener) + filterText.getEditor().setOnMouseClicked({ e -> + filterText.getEditor().getStyleClass().clear() + filterText.getEditor().getStyleClass().add('text-input') + }) + } + + + def filterOnIp() { + Finding f = mainTable.selectionModel.selectedItem + filterText.setValue(String.format("IP == '%s'", f.ip)) + } + + def filterOnPort() { + Finding f = mainTable.selectionModel.selectedItem + filterText.setValue(String.format("PORT == '%s'", f.port)) + } + + def filterOnService() { + Finding f = mainTable.selectionModel.selectedItem + filterText.setValue(String.format("SERVICE == '%s'", f.service)) + } + + def filterOnPlugin() { + Finding f = mainTable.selectionModel.selectedItem + def plugin = f.plugin + filterText.setValue(plugin.contains('\'')?String.format("PLUGIN == \"%s\"", plugin):String.format("PLUGIN == '%s'", plugin)) + } + + // TODO: adjust to list to support multiline select + def modifyEntry() { + mainApp.showEditor(mainTable.selectionModel.selectedItem) + } + + def newAction() { + masterData.clear() + textArea.getEngine().loadContent('') + } + + + RetentionFileChooser openFileChooser = new RetentionFileChooser() + + def openAction() { + openFiles(openFileChooser.showOpenMultipleDialog(mainTable.getScene().getWindow())) + } + + def exportAction() {} + + def closeAction() { + System.exit(0) + } + + def aboutAction() { + mainApp.showAbout() + } + + def filterTable() { + if (filterText.getValue() != null && filterText.getValue() != "") { + FindingPredicate fp = null + try { + fp = findingPredicateParser.parse(filterText.getValue()) + if (fp != null) { + filteredData.setPredicate(fp) + if (!filterText.getItems().contains(filterText.getValue())) { + List list = new ArrayList() + list.add(fp.toString()) + list.addAll(filterText.getItems()) + filterText.getItems().clear() + filterText.getItems().addAll(list) + filterText.setValue(fp.toString()) + } + } else { + clearFilter() + } + } catch (StringIndexOutOfBoundsException e) { + filterText.getEditor().getStyleClass().add("text-input-wrong") + statusLabel.requestFocus() + } catch (FindingPredicateParserRuntimeException ex) { + filterText.getEditor().getStyleClass().add("text-input-wrong") + statusLabel.requestFocus() + } + } + } + + @FXML + def clearFilter() { + filterText.setValue(null) + filterText.getEditor().getStyleClass().clear() + filterText.getEditor().getStyleClass().add("text-input") + filteredData.setPredicate({ f -> true }) + } + + def openFiles(List files) { + mainApp.showProgressDialog(files, statusLabel) + } + + + def copyUniqueIps() { + Set ips = new TreeSet<>() + filteredData.each { ips << it.ip } + ips.remove('none') // FIXME due to NetSparkerParser + def sorted = ips.sort { a, b -> + def ip1 = a.split("\\.") + def ip2 = b.split("\\.") + def uip1 = String.format("%3s.%3s.%3s.%3s", ip1[0], ip1[1], ip1[2], ip1[3]) + def uip2 = String.format("%3s.%3s.%3s.%3s", ip2[0], ip2[1], ip2[2], ip2[3]) + uip1 <=> uip2 + } + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard() + clpbrd.setContents(new StringSelection(sorted.join("\n")), null) + } + + def copyUniquePortsAndIps() { + Set ips = new TreeSet<>() + filteredData.each { f -> + String port = f.port.split('/')[0] + if (port.isNumber() && port != '0') { + if (!f.ip.equalsIgnoreCase('none')) // FIXME due to NetSparkerParser + ips << f.ip + ":" + port + } + } + def sorted = ips.sort { a, b -> + def ip1 = a.split(":")[0].split("\\.") + def ip2 = b.split(":")[0].split("\\.") + def uip1 = String.format("%03d.%03d.%03d.%03d.%05d", ip1[0] as int, ip1[1] as int, ip1[2] as int, ip1[3] as int, (a.split(":")[1]) as int) + def uip2 = String.format("%03d.%03d.%03d.%03d.%05d", ip2[0] as int, ip2[1] as int, ip2[2] as int, ip2[3] as int, (b.split(":")[1]) as int) + uip1 <=> uip2 + } + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard() + clpbrd.setContents(new StringSelection(sorted.join("\n")), null) + } +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/controller/FindingService.groovy b/src/main/groovy/net/vdbaan/issuefinder/controller/FindingService.groovy new file mode 100644 index 0000000..a8ae59f --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/controller/FindingService.groovy @@ -0,0 +1,31 @@ +package net.vdbaan.issuefinder.controller + +import javafx.collections.FXCollections +import javafx.collections.ObservableList +import javafx.concurrent.Service +import javafx.concurrent.Task +import net.vdbaan.issuefinder.model.Finding +import net.vdbaan.issuefinder.util.Parser + +class FindingService extends Service> { + File file + + FindingService(File file) { + this.file = file + } + @Override + protected Task> createTask() { + return new Task>() { + @Override + protected ObservableList call() { + ObservableList answer = FXCollections.observableArrayList() + try { + Parser p = Parser.getParser(file.getText()) + answer.addAll(p.parse()) + } finally { + return answer + } + } + } + } +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/controller/FormattedTableCellFactory.groovy b/src/main/groovy/net/vdbaan/issuefinder/controller/FormattedTableCellFactory.groovy new file mode 100644 index 0000000..9419384 --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/controller/FormattedTableCellFactory.groovy @@ -0,0 +1,27 @@ +package net.vdbaan.issuefinder.controller + +import javafx.scene.control.TableCell +import javafx.scene.control.TableColumn +import javafx.util.Callback +import net.vdbaan.issuefinder.model.Finding + +class FormattedTableCellFactory implements Callback, TableCell> { + @Override + TableCell call(TableColumn param) { + + List styles = ['cell','indexed-cell','table-cell','table-column'] + TableCell result = new TableCell() { + + @Override + protected void updateItem(Finding.Severity item, boolean empty) { + super.updateItem(item, empty) + setText(item.toString()) + + getStyleClass().clear() + getStyleClass().addAll(styles) + getStyleClass().add(item.toString()) + } + } + return result + } +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/controller/ProgressController.groovy b/src/main/groovy/net/vdbaan/issuefinder/controller/ProgressController.groovy new file mode 100644 index 0000000..e20f398 --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/controller/ProgressController.groovy @@ -0,0 +1,124 @@ +package net.vdbaan.issuefinder.controller + +import javafx.beans.InvalidationListener +import javafx.beans.binding.Bindings +import javafx.beans.property.SimpleBooleanProperty +import javafx.beans.property.SimpleDoubleProperty +import javafx.collections.ObservableList +import javafx.concurrent.Service +import javafx.concurrent.Worker +import javafx.fxml.FXML +import javafx.fxml.Initializable +import javafx.scene.control.Label +import javafx.scene.control.ProgressBar +import javafx.stage.Stage +import net.vdbaan.issuefinder.model.Finding + +class ProgressController implements Initializable { + @FXML + ProgressBar working + @FXML + ProgressBar files + Label statusLabel + List fileList + Stage dialogPane + ObservableList masterData + + + SimpleBooleanProperty finished = new SimpleBooleanProperty(false) + SimpleDoubleProperty progress = new SimpleDoubleProperty(0) + + @Override + void initialize(URL url, ResourceBundle rb) { + files.progressProperty().bind(progress) + working.progressProperty().bind( + Bindings + .when(finished) + .then(new SimpleDoubleProperty(1)) + .otherwise(new SimpleDoubleProperty(ProgressBar.INDETERMINATE_PROGRESS))) + } + + def process() { + int total = fileList.size() + int done = 0 + fileList.each{ it -> + Service> service = new FindingService(it) + service.stateProperty().addListener({ + if (service.getState().equals(Worker.State.SUCCEEDED)) { + masterData.addAll(service.getValue()) + done += 1 + progress.set((Double)(done/total)) + finished.set(progress == 1) + if(done == total) { + dialogPane.hide() + statusLabel.setText('Done importing') + } + } + } as InvalidationListener) + service.start() + } + } +} + +/* + statusLabel.setText('Processing files') + int total = files.size() + int done = 0 + SimpleDoubleProperty progress = new SimpleDoubleProperty(0) + SimpleBooleanProperty finished = new SimpleBooleanProperty(false) + Stage dialog = new Stage() + GridPane progressPane = new GridPane() + progressPane.setStyle("-fx-border-color: black; -fx-border-width: 2; -fx-background-color: cornsilk;") + progressPane.setPadding(new Insets(5,5,5,5)) + progressPane.setHgap(5) + progressPane.setVgap(5) + Label lbl = new Label('Processing new files') + lbl.setFont(Font.font(24)) + + progressPane.add(lbl,0,0,2,1) + progressPane.addRow(1, new Label("File: :"), createBoundProgressBar(progress)) + progressPane.addRow(2, new Label("Processing:"), + createBoundProgressBar( + Bindings + .when(finished) + .then(new SimpleDoubleProperty(1)) + .otherwise(new SimpleDoubleProperty(ProgressBar.INDETERMINATE_PROGRESS)) + ) + ) + + + dialog.initOwner(mainTable.getScene().getWindow()) + dialog.initStyle(StageStyle.UNDECORATED) + dialog.setScene(new Scene(progressPane)) + dialog.initStyle(StageStyle.UNDECORATED) + dialog.show() + files.each { it -> + println 'Working on '+it.getAbsolutePath() + Service> service = new FindingService(it) + service.stateProperty().addListener({ + if (service.getState().equals(Worker.State.SUCCEEDED)) { + println 'Done parsing' + masterData.addAll(service.getValue()) + done += 1 + progress.set((Double)(done/total)) + finished.set(progress == 1) + println String.format("%d of %d to go",done,total) + if(done == total) { + dialog.hide() + statusLabel.setText('Done importing') + } + } + } as InvalidationListener) + println 'Starting service' + service.start() + } + + private ProgressBar createBoundProgressBar(NumberExpression progressProperty) { + ProgressBar progressBar = new ProgressBar(); + progressBar.setMaxWidth(Double.MAX_VALUE); + progressBar.setPrefWidth(400.0) + progressBar.progressProperty().bind(progressProperty); + GridPane.setHgrow(progressBar, Priority.ALWAYS); + return progressBar; + } + */ \ No newline at end of file diff --git a/src/main/groovy/net/vdbaan/issuefinder/filter/FindingPredicate.groovy b/src/main/groovy/net/vdbaan/issuefinder/filter/FindingPredicate.groovy new file mode 100644 index 0000000..4541f9b --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/filter/FindingPredicate.groovy @@ -0,0 +1,154 @@ +package net.vdbaan.issuefinder.filter + +import net.vdbaan.issuefinder.model.Finding + +import java.util.concurrent.ConcurrentHashMap +import java.util.function.Predicate + +enum ColumnName { + SCANNER("SCANNER"), IP("IP"), PORT("PORT"), SERVICE("SERVICE"), RISK("RISK"), + EXPLOITABLE("EXPLOITABLE"), DESCRIPTION("DESCRIPTION"), PLUGIN('PLUGIN') + private String value + private static final Map ENUM_MAP + + ColumnName(String value) { + this.value = value + } + + String getValue() { + return value + } + + @Override + String toString() { + return getValue() + } + + static { + Map map = new ConcurrentHashMap<>() + for (ColumnName instance : ColumnName.values()) { + map.put(instance.getValue(), instance) + } + ENUM_MAP = Collections.unmodifiableMap(map) + } + + static ColumnName get(String name) { + return ENUM_MAP.get(name) + } + + Object get(Finding f) { + switch (this) { + case SCANNER: return f.scanner + case IP: return f.ip + case PORT: return f.port + case SERVICE: return f.service + case RISK: return f.severity.toString() + case EXPLOITABLE: return f.exploitable + case DESCRIPTION: return f.fullDescription() + } + } +} + +class FindingPredicate implements Predicate { + enum LogicalOperation { + LT("<"), LE("<="), GT(">"), GE(">="), EQ("=="), NE("!="), LIKE("LIKE"), APROX("~="), NOT("!"), + AND("&&"), OR("||"), IN("IN"), BETWEEN("BETWEEN") + final String representation + + private static final Map ENUM_MAP + + LogicalOperation(String s) { + representation = s + } + + String getRepresentation() { + return representation + } + + static { + Map map = new ConcurrentHashMap<>() + for (LogicalOperation instance : LogicalOperation.values()) { + map.put(instance.getRepresentation(), instance) + } + ENUM_MAP = Collections.unmodifiableMap(map) + } + + static LogicalOperation get(String name) { + return ENUM_MAP.get(name) + } + } + + FindingPredicate(Object left, LogicalOperation operation, Object right) { + this.left = left + this.operation = operation + this.right = right + } + + Object left + LogicalOperation operation + Object right + + boolean test(Finding f) { + Object lValue = this.left, rValue = this.right + if (left instanceof ColumnName) { + lValue = ((ColumnName) left).get(f) + } + + if (right instanceof ColumnName) { + rValue = ((ColumnName) right).get(f) + } + if (lValue == null || (rValue == null && operation != LogicalOperation.NOT)) { + return false + } + if (ColumnName.RISK == left) { + rValue = rValue.toString().toUpperCase() + } + switch (operation) { + case LogicalOperation.AND:return ((FindingPredicate) lValue).and((FindingPredicate) rValue).test(f) + case LogicalOperation.OR: return ((FindingPredicate) lValue).or((FindingPredicate) rValue).test(f) + + case LogicalOperation.EQ: return lValue.equals(rValue) + case LogicalOperation.NE: return !lValue.equals(rValue) + case LogicalOperation.LIKE: return ((String) lValue).contains(rValue) + + case LogicalOperation.LT: return ((String)lValue).compareTo(rValue) <0 + case LogicalOperation.LE: return ((String)lValue).compareTo(rValue) <=0 + case LogicalOperation.GT: return ((String)lValue).compareTo(rValue) >0 + case LogicalOperation.GE: return ((String)lValue).compareTo(rValue) >=0 + + case LogicalOperation.NOT: return (lValue instanceof FindingPredicate) ? + ((FindingPredicate) lValue).negate().test(f) : !((Boolean) lValue).booleanValue() + + + case LogicalOperation.IN: return ((List)rValue).contains(lValue) + case LogicalOperation.BETWEEN: return between(lValue, rValue) + default: return true + + } + } + + + boolean between(Object column, Object value) { + List list = (List) value + Object low = list.get(0) + Object high = list.get(1) + return ((String)column).compareTo(low)>=0 && + ((String)column).compareTo(high) <=0 + } + String toString() { + if (left instanceof ColumnName) { + if (operation == LogicalOperation.NOT) { + return "!" + ((ColumnName) left) + } else { + return String.format("%s %s %s", (left instanceof FindingPredicate) ? "(" + left + ")" : left, operation.representation, (right instanceof FindingPredicate) ? "(" + right + ")" : "'"+right+"'") + } + } else if (left instanceof FindingPredicate) { + if (operation == LogicalOperation.NOT) { + return "!(" + left.toString() + ")" + } else { + return String.format("%s %s %s", (left instanceof FindingPredicate) ? "(" + left + ")" : left, operation.representation, (right instanceof FindingPredicate) ? "(" + right + ")" : "'"+right+"'") + } + } + + } +} diff --git a/src/main/groovy/net/vdbaan/issuefinder/filter/PredicateParser.groovy b/src/main/groovy/net/vdbaan/issuefinder/filter/PredicateParser.groovy new file mode 100644 index 0000000..03cd7e1 --- /dev/null +++ b/src/main/groovy/net/vdbaan/issuefinder/filter/PredicateParser.groovy @@ -0,0 +1,145 @@ +package net.vdbaan.issuefinder.filter + + +import org.antlr.v4.runtime.BaseErrorListener +import org.antlr.v4.runtime.CharStreams +import org.antlr.v4.runtime.CommonTokenStream +import org.antlr.v4.runtime.RecognitionException +import org.antlr.v4.runtime.Recognizer +import org.antlr.v4.runtime.atn.PredictionMode +import org.antlr.v4.runtime.tree.ParseTree + +class FindingPredicateParserRuntimeException extends RuntimeException { + FindingPredicateParserRuntimeException(String message) { + super(message) + } +} + +class FindingPredicateParser { + static void main(String[] args) { +// String txt = "(IP == \"127.0.0.1\") && ((!EXPLOITABLE) || ((PORT LIKE \"443\") && !(SERVICE LIKE 'http'))) || (RISK IN [HIGH,LOW])"; + String txt = "(IP == \"127.0.0.1\") && ((!EXPLOITABLE) || ((PORT LIKE \"443\") && !(SERVICE LIKE 'http')) || (RISK BETWEEN (LOW,CRITICAL)))" + FindingPredicateParser fpp = new FindingPredicateParser() + println fpp.parse(txt) + } + + FindingPredicate parse(String text) { + PredicateLexer lexer = new PredicateLexer(CharStreams.fromString(text)) + CommonTokenStream tokens = new CommonTokenStream(lexer) + PredicateParser parser = new PredicateParser(tokens) + parser.removeErrorListeners() + parser.addErrorListener(new BaseErrorListener() { + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { + super.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) + throw new FindingPredicateParserRuntimeException("error") + } + }) + parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION) + ParseTree tree = parser.expr() + FindingPredicateVisitor v = new FindingPredicateVisitor() + try { + FindingPredicate fp = (FindingPredicate) v.visit(tree) + return fp + } catch (FindingPredicateParserRuntimeException r) { + return null + } + } +} + +class FindingPredicateVisitor extends PredicateBaseVisitor { + /* + expr AND expr # andExpr + | expr OR expr # orExpr + | LPAREN expr RPAREN # enclosedExpr + | NOT expr # notExpr + | column operator STRING # assign + | column rangeOperator RANGE # range + | column groupOperator GROUP # group + | NOT column # notColumn + */ + + @Override + Object visitAndExpr(PredicateParser.AndExprContext ctx) { + return new FindingPredicate(visit(ctx.expr(0)), FindingPredicate.LogicalOperation.AND, visit(ctx.expr(1))) + } + + @Override + Object visitOrExpr(PredicateParser.OrExprContext ctx) { + return new FindingPredicate(visit(ctx.expr(0)), FindingPredicate.LogicalOperation.OR, visit(ctx.expr(1))) + } + + @Override + Object visitEnclosedExpr(PredicateParser.EnclosedExprContext ctx) { + return visit(ctx.expr()) + } + + @Override + Object visitNotExpr(PredicateParser.NotExprContext ctx) { + return new FindingPredicate(visit(ctx.expr()), FindingPredicate.LogicalOperation.NOT, null) + } + + @Override + Object visitAssign(PredicateParser.AssignContext ctx) { + return new FindingPredicate(visit(ctx.column()), (FindingPredicate.LogicalOperation) visit(ctx.operator()), stripQuotes(ctx.STRING().text)) + } + + @Override + Object visitRange(PredicateParser.RangeContext ctx) { + ArrayList list = buildList(ctx.RANGE().text) + return new FindingPredicate(visit(ctx.column()), (FindingPredicate.LogicalOperation) visit(ctx.rangeOperator()), list) + } + + @Override + Object visitGroup(PredicateParser.GroupContext ctx) { + return new FindingPredicate(visit(ctx.column()), (FindingPredicate.LogicalOperation) visit(ctx.groupOperator()), buildList(ctx.GROUP().text)) + } + + @Override + Object visitNotColumn(PredicateParser.NotColumnContext ctx) { + return new FindingPredicate(visit(ctx.column()), FindingPredicate.LogicalOperation.NOT, null) + } + + + @Override + Object visitColumn(PredicateParser.ColumnContext ctx) { + return ColumnName.get(ctx.text.toUpperCase()) + } + + @Override + Object visitOperator(PredicateParser.OperatorContext ctx) { + return FindingPredicate.LogicalOperation.get(ctx.text.toUpperCase()) + } + + @Override + Object visitGroupOperator(PredicateParser.GroupOperatorContext ctx) { + return FindingPredicate.LogicalOperation.get(ctx.text.toUpperCase()) + } + + @Override + Object visitRangeOperator(PredicateParser.RangeOperatorContext ctx) { + return FindingPredicate.LogicalOperation.get(ctx.text.toUpperCase()) + } + + protected Object aggregateResult(Object aggregate, Object nextResult) { + if (nextResult == null) return aggregate + return super.aggregateResult(aggregate, nextResult) + } + + private String stripQuotes(String text) { + if (text.startsWith('"') || text.startsWith("'")) { + def len = text.length() + return text.substring(1, len - 1) + } else return text + } + + private List buildList(String list) { + ArrayList result = new ArrayList() + def len = list.length() + String workable = list.substring(1, len - 1) + workable.tokenize(",").each { token -> + result << stripQuotes(token) + } + return result + } +} \ No newline at end of file diff --git a/src/main/groovy/net/vdbaan/issuefinder/model/Finding.groovy b/src/main/groovy/net/vdbaan/issuefinder/model/Finding.groovy index 634dbe8..83f9039 100755 --- a/src/main/groovy/net/vdbaan/issuefinder/model/Finding.groovy +++ b/src/main/groovy/net/vdbaan/issuefinder/model/Finding.groovy @@ -1,38 +1,29 @@ -/* - * Copyright (C) 2017 S. van der Baan - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ +package net.vdbaan.issuefinder.model + +import groovy.transform.Canonical +import groovyx.javafx.beans.FXBindable - package net.vdbaan.issuefinder.model +/** + * Created by Steven on 31/08/2017. + */ + class Finding { enum Severity { CRITICAL, HIGH, MEDIUM, LOW, INFO, UNKNOWN } - String scanner= '' - String ip= '' - String hostName= '' - String port= '' - String service= '' - String plugin = '' - Severity severity = Severity.UNKNOWN - String summary = '' - String baseCVSS = '0.0' - Boolean exploitable = false + @FXBindable String scanner= '' + @FXBindable String ip= '' + @FXBindable String hostName= '' + @FXBindable String port= '' + @FXBindable String service= '' + @FXBindable String plugin = '' + @FXBindable Severity severity = Severity.UNKNOWN + @FXBindable String summary = '' + @FXBindable String baseCVSS = '0.0' + @FXBindable Boolean exploitable = false @Override String toString() { @@ -45,6 +36,9 @@ class Finding { "=============================================\n"+"summary:\n%s\n", scanner, ip, port, service, plugin, severity, summary) } + String htmlDescription() { + return String.format("scanner: %s
source: %s:%s
service: %s
plugin: %s
risk: %s
"+ + "
"+"summary:
%s", + scanner, ip, port, service, plugin, severity, summary.replace('\n','
')) + } } - - diff --git a/src/main/groovy/net/vdbaan/issuefinder/util/BurpParser.groovy b/src/main/groovy/net/vdbaan/issuefinder/util/BurpParser.groovy index a39bd08..cfc79b4 100755 --- a/src/main/groovy/net/vdbaan/issuefinder/util/BurpParser.groovy +++ b/src/main/groovy/net/vdbaan/issuefinder/util/BurpParser.groovy @@ -32,6 +32,14 @@ class BurpParser extends Parser{ } List parse() { + String version = content.@burpVersion + if (version.compareTo("1.7.27")>= 0) { + return parse1727() + } else + return parseOther() + } + + List parseOther() { List result = new ArrayList<>() content.issue.each {issue -> // scanner, ip, port, service, plugin, severity, summary @@ -42,10 +50,66 @@ class BurpParser extends Parser{ result << new Finding([scanner:scanner, ip:ip, port:port+'/open/tcp', service:service, plugin:issue.name as String, severity:calc(issue.severity, issue.confidence), summary:buildSummary(issue)]) + } return result } + class FindingWrapper { + Finding finding + Set locations = new HashSet() + String toString() { + StringBuilder sb = new StringBuilder() + sb.append(finding.fullDescription()) + sb.append(locations.join(', ')) + return sb.toString() + } + } + List parse1727() { + List result = new ArrayList<>() + Map base = new HashMap<>() + + content.issue.each {issue -> + // scanner, ip, port, service, plugin, severity, summary + def url = new URL(issue.host as String) + def ip = (issue.host.@ip ?: url.getHost()) as String + def port = url.getPort() as String + + def service = url.protocol.toUpperCase() + def plugin = String.format("(%s) %s", issue.type, issue.name) + if (port == '-1') port = (service == 'HTTPS') ? '443' : '80' + String location = issue.location + def f = new Finding([scanner: scanner, ip: ip, port: port + '/open/tcp', service: service, + plugin : plugin, severity: calc(issue.severity, issue.confidence), + summary: buildSummary1727(issue)]) + + def key = ip+':'+port + + Map temp + if(base.containsKey(key)) { + temp = base.get(key) + }else { + temp = new HashMap<>() + } + FindingWrapper fw + if (temp.containsKey(plugin)) { + fw = temp.get(plugin) + } else { + fw = new FindingWrapper(finding: f) + } + fw.locations.add(location) + temp.put(plugin,fw) + base.put(key, temp) + } + base.each {url,map -> + map.each {plugin,wrap -> + Finding find = wrap.finding + find.summary = find.summary.replace('PLACEHOLDER','\n'+wrap.locations.join('\n')) + result << find + } + } + return result + } private Finding.Severity calc(severity,confidence) { switch (severity) { case 'High':return Finding.Severity.HIGH @@ -66,4 +130,32 @@ class BurpParser extends Parser{ return summary } + + private String buildSummary1727(issue) { + String summary = "Name : " + issue.name + summary += "\nDetail : " + issue.issueDetail + summary += "\npath : PLACEHOLDER" + summary += "\nlocation : PLACEHOLDER" + summary += "\nSeverity : " + issue.severity+ " (" + issue.confidence + ")" + summary += "\nBackground : " + issue.issueBackground + summary += "\nRemediation: " + issue.remediationDetail + + return summary + } + + List mergeFindings(List result) { + + result.each{ + + } + return result + } + + static void main(String... args) { + def burpFile = new File("C:\\Users\\Steven\\Documents\\1.Clients\\53375 - ADCS-008 - advanced computer software\\Work/burp-report.xml") + Parser parser = Parser.getParser(burpFile.text) + parser.parse().each { it -> + println it.fullDescription() + } + } } diff --git a/src/main/groovy/net/vdbaan/issuefinder/util/Parser.groovy b/src/main/groovy/net/vdbaan/issuefinder/util/Parser.groovy index b17ef97..f138ea4 100755 --- a/src/main/groovy/net/vdbaan/issuefinder/util/Parser.groovy +++ b/src/main/groovy/net/vdbaan/issuefinder/util/Parser.groovy @@ -23,13 +23,13 @@ import groovy.json.JsonSlurper import org.apache.commons.pool2.BasePooledObjectFactory import org.apache.commons.pool2.PooledObject import org.apache.commons.pool2.impl.GenericObjectPool -import org.apache.commons.pool2.PooledObjectFactory import org.apache.commons.pool2.impl.DefaultPooledObject import org.apache.commons.pool2.impl.GenericObjectPoolConfig -import javax.xml.parsers.SAXParser import javax.xml.parsers.SAXParserFactory +//import javax.xml.parsers.SAXParserFactory + abstract class Parser { def content @@ -102,7 +102,7 @@ class XmlParserPoolableObjectFactory extends BasePooledObjectFactory { } class XmlParserPool { - private final GenericObjectPool pool; + private final GenericObjectPool pool XmlParserPool(int maxActive) { def gen = new GenericObjectPoolConfig() diff --git a/src/main/java/net/vdbaan/issuefinder/filechooser/RetentionFileChooser.java b/src/main/java/net/vdbaan/issuefinder/filechooser/RetentionFileChooser.java new file mode 100644 index 0000000..2a967c5 --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filechooser/RetentionFileChooser.java @@ -0,0 +1,58 @@ +package net.vdbaan.issuefinder.filechooser; + +import javafx.beans.property.SimpleObjectProperty; +import javafx.stage.FileChooser; +import javafx.stage.Window; + +import java.io.File; +import java.util.List; + +public class RetentionFileChooser { + private static FileChooser instance = null; + private static SimpleObjectProperty lastKnownDirectoryProperty = new SimpleObjectProperty<>(); + + private RetentionFileChooser(){ } + + private static FileChooser getInstance(){ + if(instance == null) { + instance = new FileChooser(); + instance.initialDirectoryProperty().bindBidirectional(lastKnownDirectoryProperty); + + } + return instance; + } + + public static File showOpenDialog(){ + return showOpenDialog(null); + } + + + public List showOpenMultipleDialog(final Window ownerWindow) { + List result = getInstance().showOpenMultipleDialog(ownerWindow); + if(result != null) { + lastKnownDirectoryProperty.setValue(result.get(0).getParentFile()); + } + return result; + } + public static File showOpenDialog(Window ownerWindow){ + File chosenFile = getInstance().showOpenDialog(ownerWindow); + if(chosenFile != null){ + //Set the property to the directory of the chosenFile so the fileChooser will open here next + lastKnownDirectoryProperty.setValue(chosenFile.getParentFile()); + } + return chosenFile; + } + + public static File showSaveDialog(){ + return showSaveDialog(null); + } + + public static File showSaveDialog(Window ownerWindow){ + File chosenFile = getInstance().showSaveDialog(ownerWindow); + if(chosenFile != null){ + //Set the property to the directory of the chosenFile so the fileChooser will open here next + lastKnownDirectoryProperty.setValue(chosenFile.getParentFile()); + } + return chosenFile; + } +} \ No newline at end of file diff --git a/src/main/java/net/vdbaan/issuefinder/filter/Predicate.tokens b/src/main/java/net/vdbaan/issuefinder/filter/Predicate.tokens new file mode 100644 index 0000000..6aa1d64 --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/Predicate.tokens @@ -0,0 +1,42 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +LPAREN=8 +RPAREN=9 +AND=10 +OR=11 +NOT=12 +IP=13 +SCANNER=14 +PORT=15 +SERVICE=16 +RISK=17 +EXPLOITABLE=18 +DESCRIPTION=19 +PLUGIN=20 +IN=21 +LIKE=22 +BETWEEN=23 +GROUP=24 +RANGE=25 +STRING=26 +SQUOTE=27 +DQUOTE=28 +CHAR=29 +WS=30 +'=='=1 +'!='=2 +'<'=3 +'<='=4 +'>'=5 +'=>'=6 +'~='=7 +'('=8 +')'=9 +'!'=12 +'\''=27 +'"'=28 diff --git a/src/main/java/net/vdbaan/issuefinder/filter/PredicateBaseListener.java b/src/main/java/net/vdbaan/issuefinder/filter/PredicateBaseListener.java new file mode 100644 index 0000000..911b69f --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/PredicateBaseListener.java @@ -0,0 +1,185 @@ +// Generated from C:/Users/Steven/Documents/4.Projects/IssueFinder/src/main/antlr\Predicate.g4 by ANTLR 4.7 + +package net.vdbaan.issuefinder.filter; + + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link PredicateListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +public class PredicateBaseListener implements PredicateListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEnclosedExpr(PredicateParser.EnclosedExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEnclosedExpr(PredicateParser.EnclosedExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNotExpr(PredicateParser.NotExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNotExpr(PredicateParser.NotExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterRange(PredicateParser.RangeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitRange(PredicateParser.RangeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNotColumn(PredicateParser.NotColumnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNotColumn(PredicateParser.NotColumnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOrExpr(PredicateParser.OrExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOrExpr(PredicateParser.OrExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssign(PredicateParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssign(PredicateParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGroup(PredicateParser.GroupContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGroup(PredicateParser.GroupContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAndExpr(PredicateParser.AndExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAndExpr(PredicateParser.AndExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterColumn(PredicateParser.ColumnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitColumn(PredicateParser.ColumnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGroupOperator(PredicateParser.GroupOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGroupOperator(PredicateParser.GroupOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterRangeOperator(PredicateParser.RangeOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitRangeOperator(PredicateParser.RangeOperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOperator(PredicateParser.OperatorContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOperator(PredicateParser.OperatorContext ctx) { } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/src/main/java/net/vdbaan/issuefinder/filter/PredicateBaseVisitor.java b/src/main/java/net/vdbaan/issuefinder/filter/PredicateBaseVisitor.java new file mode 100644 index 0000000..79eaba0 --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/PredicateBaseVisitor.java @@ -0,0 +1,100 @@ +// Generated from C:/Users/Steven/Documents/4.Projects/IssueFinder/src/main/antlr\Predicate.g4 by ANTLR 4.7 + +package net.vdbaan.issuefinder.filter; + +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link PredicateVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public class PredicateBaseVisitor extends AbstractParseTreeVisitor implements PredicateVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEnclosedExpr(PredicateParser.EnclosedExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNotExpr(PredicateParser.NotExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitRange(PredicateParser.RangeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNotColumn(PredicateParser.NotColumnContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitOrExpr(PredicateParser.OrExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAssign(PredicateParser.AssignContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGroup(PredicateParser.GroupContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAndExpr(PredicateParser.AndExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitColumn(PredicateParser.ColumnContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGroupOperator(PredicateParser.GroupOperatorContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitRangeOperator(PredicateParser.RangeOperatorContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitOperator(PredicateParser.OperatorContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/net/vdbaan/issuefinder/filter/PredicateLexer.java b/src/main/java/net/vdbaan/issuefinder/filter/PredicateLexer.java new file mode 100644 index 0000000..82369dc --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/PredicateLexer.java @@ -0,0 +1,228 @@ +// Generated from C:/Users/Steven/Documents/4.Projects/IssueFinder/src/main/antlr\Predicate.g4 by ANTLR 4.7 + +package net.vdbaan.issuefinder.filter; + +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class PredicateLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, LPAREN=8, RPAREN=9, + AND=10, OR=11, NOT=12, IP=13, SCANNER=14, PORT=15, SERVICE=16, RISK=17, + EXPLOITABLE=18, DESCRIPTION=19, PLUGIN=20, IN=21, LIKE=22, BETWEEN=23, + GROUP=24, RANGE=25, STRING=26, SQUOTE=27, DQUOTE=28, CHAR=29, WS=30; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + public static final String[] ruleNames = { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "LPAREN", "RPAREN", + "AND", "OR", "NOT", "IP", "SCANNER", "PORT", "SERVICE", "RISK", "EXPLOITABLE", + "DESCRIPTION", "PLUGIN", "IN", "LIKE", "BETWEEN", "GROUP", "RANGE", "STRING", + "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", + "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "SQUOTE", + "DQUOTE", "CHAR", "WS" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'=='", "'!='", "'<'", "'<='", "'>'", "'=>'", "'~='", "'('", "')'", + null, null, "'!'", null, null, null, null, null, null, null, null, null, + null, null, null, null, null, "'''", "'\"'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, null, null, null, null, null, null, "LPAREN", "RPAREN", "AND", + "OR", "NOT", "IP", "SCANNER", "PORT", "SERVICE", "RISK", "EXPLOITABLE", + "DESCRIPTION", "PLUGIN", "IN", "LIKE", "BETWEEN", "GROUP", "RANGE", "STRING", + "SQUOTE", "DQUOTE", "CHAR", "WS" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public PredicateLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Predicate.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2 \u0150\b\1\4\2\t"+ + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ + ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ + "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\3\2\3\2\3\2\3\3\3\3\3\3"+ + "\3\4\3\4\3\5\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3"+ + "\13\3\13\3\13\3\13\3\13\5\13\u0090\n\13\3\f\3\f\3\f\3\f\5\f\u0096\n\f"+ + "\3\r\3\r\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3"+ + "\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3"+ + "\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3"+ + "\23\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\25\3"+ + "\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3"+ + "\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3\31\6\31\u00ea"+ + "\n\31\r\31\16\31\u00eb\3\31\3\31\3\32\3\32\3\32\3\32\3\32\3\32\3\33\3"+ + "\33\6\33\u00f8\n\33\r\33\16\33\u00f9\3\33\3\33\3\33\3\33\6\33\u0100\n"+ + "\33\r\33\16\33\u0101\3\33\3\33\3\33\5\33\u0107\n\33\3\34\3\34\3\35\3\35"+ + "\3\36\3\36\3\37\3\37\3 \3 \3!\3!\3\"\3\"\3#\3#\3$\3$\3%\3%\3&\3&\3\'\3"+ + "\'\3(\3(\3)\3)\3*\3*\3+\3+\3,\3,\3-\3-\3.\3.\3/\3/\3\60\3\60\3\61\3\61"+ + "\3\62\3\62\3\63\3\63\3\64\3\64\3\65\3\65\3\66\3\66\3\66\3\66\3\67\3\67"+ + "\3\67\3\67\38\68\u0146\n8\r8\168\u0147\39\69\u014b\n9\r9\169\u014c\39"+ + "\39\4\u00f9\u0101\2:\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27"+ + "\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33"+ + "\65\34\67\29\2;\2=\2?\2A\2C\2E\2G\2I\2K\2M\2O\2Q\2S\2U\2W\2Y\2[\2]\2_"+ + "\2a\2c\2e\2g\2i\2k\35m\36o\37q \3\2 \3\2$$\3\2))\4\2CCcc\4\2DDdd\4\2E"+ + "Eee\4\2FFff\4\2GGgg\4\2HHhh\4\2IIii\4\2JJjj\4\2KKkk\4\2LLll\4\2MMmm\4"+ + "\2NNnn\4\2OOoo\4\2PPpp\4\2QQqq\4\2RRrr\4\2SSss\4\2TTtt\4\2UUuu\4\2VVv"+ + "v\4\2WWww\4\2XXxx\4\2YYyy\4\2ZZzz\4\2[[{{\4\2\\\\||\6\2\60=C\\^^c|\5\2"+ + "\13\f\17\17\"\"\2\u013e\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2"+ + "\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25"+ + "\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2"+ + "\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2"+ + "\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2k\3\2"+ + "\2\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\3s\3\2\2\2\5v\3\2\2\2\7y\3\2\2\2"+ + "\t{\3\2\2\2\13~\3\2\2\2\r\u0080\3\2\2\2\17\u0083\3\2\2\2\21\u0086\3\2"+ + "\2\2\23\u0088\3\2\2\2\25\u008f\3\2\2\2\27\u0095\3\2\2\2\31\u0097\3\2\2"+ + "\2\33\u0099\3\2\2\2\35\u009c\3\2\2\2\37\u00a4\3\2\2\2!\u00a9\3\2\2\2#"+ + "\u00b1\3\2\2\2%\u00b6\3\2\2\2\'\u00c2\3\2\2\2)\u00ce\3\2\2\2+\u00d5\3"+ + "\2\2\2-\u00d8\3\2\2\2/\u00dd\3\2\2\2\61\u00e5\3\2\2\2\63\u00ef\3\2\2\2"+ + "\65\u0106\3\2\2\2\67\u0108\3\2\2\29\u010a\3\2\2\2;\u010c\3\2\2\2=\u010e"+ + "\3\2\2\2?\u0110\3\2\2\2A\u0112\3\2\2\2C\u0114\3\2\2\2E\u0116\3\2\2\2G"+ + "\u0118\3\2\2\2I\u011a\3\2\2\2K\u011c\3\2\2\2M\u011e\3\2\2\2O\u0120\3\2"+ + "\2\2Q\u0122\3\2\2\2S\u0124\3\2\2\2U\u0126\3\2\2\2W\u0128\3\2\2\2Y\u012a"+ + "\3\2\2\2[\u012c\3\2\2\2]\u012e\3\2\2\2_\u0130\3\2\2\2a\u0132\3\2\2\2c"+ + "\u0134\3\2\2\2e\u0136\3\2\2\2g\u0138\3\2\2\2i\u013a\3\2\2\2k\u013c\3\2"+ + "\2\2m\u0140\3\2\2\2o\u0145\3\2\2\2q\u014a\3\2\2\2st\7?\2\2tu\7?\2\2u\4"+ + "\3\2\2\2vw\7#\2\2wx\7?\2\2x\6\3\2\2\2yz\7>\2\2z\b\3\2\2\2{|\7>\2\2|}\7"+ + "?\2\2}\n\3\2\2\2~\177\7@\2\2\177\f\3\2\2\2\u0080\u0081\7?\2\2\u0081\u0082"+ + "\7@\2\2\u0082\16\3\2\2\2\u0083\u0084\7\u0080\2\2\u0084\u0085\7?\2\2\u0085"+ + "\20\3\2\2\2\u0086\u0087\7*\2\2\u0087\22\3\2\2\2\u0088\u0089\7+\2\2\u0089"+ + "\24\3\2\2\2\u008a\u008b\7(\2\2\u008b\u0090\7(\2\2\u008c\u008d\7C\2\2\u008d"+ + "\u008e\7P\2\2\u008e\u0090\7F\2\2\u008f\u008a\3\2\2\2\u008f\u008c\3\2\2"+ + "\2\u0090\26\3\2\2\2\u0091\u0092\7~\2\2\u0092\u0096\7~\2\2\u0093\u0094"+ + "\7Q\2\2\u0094\u0096\7T\2\2\u0095\u0091\3\2\2\2\u0095\u0093\3\2\2\2\u0096"+ + "\30\3\2\2\2\u0097\u0098\7#\2\2\u0098\32\3\2\2\2\u0099\u009a\5G$\2\u009a"+ + "\u009b\5U+\2\u009b\34\3\2\2\2\u009c\u009d\5[.\2\u009d\u009e\5;\36\2\u009e"+ + "\u009f\5\67\34\2\u009f\u00a0\5Q)\2\u00a0\u00a1\5Q)\2\u00a1\u00a2\5? \2"+ + "\u00a2\u00a3\5Y-\2\u00a3\36\3\2\2\2\u00a4\u00a5\5U+\2\u00a5\u00a6\5S*"+ + "\2\u00a6\u00a7\5Y-\2\u00a7\u00a8\5]/\2\u00a8 \3\2\2\2\u00a9\u00aa\5[."+ + "\2\u00aa\u00ab\5? \2\u00ab\u00ac\5Y-\2\u00ac\u00ad\5a\61\2\u00ad\u00ae"+ + "\5G$\2\u00ae\u00af\5;\36\2\u00af\u00b0\5? \2\u00b0\"\3\2\2\2\u00b1\u00b2"+ + "\5Y-\2\u00b2\u00b3\5G$\2\u00b3\u00b4\5[.\2\u00b4\u00b5\5K&\2\u00b5$\3"+ + "\2\2\2\u00b6\u00b7\5? \2\u00b7\u00b8\5e\63\2\u00b8\u00b9\5U+\2\u00b9\u00ba"+ + "\5M\'\2\u00ba\u00bb\5S*\2\u00bb\u00bc\5G$\2\u00bc\u00bd\5]/\2\u00bd\u00be"+ + "\5\67\34\2\u00be\u00bf\59\35\2\u00bf\u00c0\5M\'\2\u00c0\u00c1\5? \2\u00c1"+ + "&\3\2\2\2\u00c2\u00c3\5=\37\2\u00c3\u00c4\5? \2\u00c4\u00c5\5[.\2\u00c5"+ + "\u00c6\5;\36\2\u00c6\u00c7\5Y-\2\u00c7\u00c8\5G$\2\u00c8\u00c9\5U+\2\u00c9"+ + "\u00ca\5]/\2\u00ca\u00cb\5G$\2\u00cb\u00cc\5S*\2\u00cc\u00cd\5Q)\2\u00cd"+ + "(\3\2\2\2\u00ce\u00cf\5U+\2\u00cf\u00d0\5M\'\2\u00d0\u00d1\5_\60\2\u00d1"+ + "\u00d2\5C\"\2\u00d2\u00d3\5G$\2\u00d3\u00d4\5Q)\2\u00d4*\3\2\2\2\u00d5"+ + "\u00d6\5G$\2\u00d6\u00d7\5Q)\2\u00d7,\3\2\2\2\u00d8\u00d9\5M\'\2\u00d9"+ + "\u00da\5G$\2\u00da\u00db\5K&\2\u00db\u00dc\5? \2\u00dc.\3\2\2\2\u00dd"+ + "\u00de\59\35\2\u00de\u00df\5? \2\u00df\u00e0\5]/\2\u00e0\u00e1\5c\62\2"+ + "\u00e1\u00e2\5? \2\u00e2\u00e3\5? \2\u00e3\u00e4\5Q)\2\u00e4\60\3\2\2"+ + "\2\u00e5\u00e6\7]\2\2\u00e6\u00e9\5\65\33\2\u00e7\u00e8\7.\2\2\u00e8\u00ea"+ + "\5\65\33\2\u00e9\u00e7\3\2\2\2\u00ea\u00eb\3\2\2\2\u00eb\u00e9\3\2\2\2"+ + "\u00eb\u00ec\3\2\2\2\u00ec\u00ed\3\2\2\2\u00ed\u00ee\7_\2\2\u00ee\62\3"+ + "\2\2\2\u00ef\u00f0\5\21\t\2\u00f0\u00f1\5\65\33\2\u00f1\u00f2\7.\2\2\u00f2"+ + "\u00f3\5\65\33\2\u00f3\u00f4\5\23\n\2\u00f4\64\3\2\2\2\u00f5\u00f7\5m"+ + "\67\2\u00f6\u00f8\n\2\2\2\u00f7\u00f6\3\2\2\2\u00f8\u00f9\3\2\2\2\u00f9"+ + "\u00fa\3\2\2\2\u00f9\u00f7\3\2\2\2\u00fa\u00fb\3\2\2\2\u00fb\u00fc\5m"+ + "\67\2\u00fc\u0107\3\2\2\2\u00fd\u00ff\5k\66\2\u00fe\u0100\n\3\2\2\u00ff"+ + "\u00fe\3\2\2\2\u0100\u0101\3\2\2\2\u0101\u0102\3\2\2\2\u0101\u00ff\3\2"+ + "\2\2\u0102\u0103\3\2\2\2\u0103\u0104\5k\66\2\u0104\u0107\3\2\2\2\u0105"+ + "\u0107\5o8\2\u0106\u00f5\3\2\2\2\u0106\u00fd\3\2\2\2\u0106\u0105\3\2\2"+ + "\2\u0107\66\3\2\2\2\u0108\u0109\t\4\2\2\u01098\3\2\2\2\u010a\u010b\t\5"+ + "\2\2\u010b:\3\2\2\2\u010c\u010d\t\6\2\2\u010d<\3\2\2\2\u010e\u010f\t\7"+ + "\2\2\u010f>\3\2\2\2\u0110\u0111\t\b\2\2\u0111@\3\2\2\2\u0112\u0113\t\t"+ + "\2\2\u0113B\3\2\2\2\u0114\u0115\t\n\2\2\u0115D\3\2\2\2\u0116\u0117\t\13"+ + "\2\2\u0117F\3\2\2\2\u0118\u0119\t\f\2\2\u0119H\3\2\2\2\u011a\u011b\t\r"+ + "\2\2\u011bJ\3\2\2\2\u011c\u011d\t\16\2\2\u011dL\3\2\2\2\u011e\u011f\t"+ + "\17\2\2\u011fN\3\2\2\2\u0120\u0121\t\20\2\2\u0121P\3\2\2\2\u0122\u0123"+ + "\t\21\2\2\u0123R\3\2\2\2\u0124\u0125\t\22\2\2\u0125T\3\2\2\2\u0126\u0127"+ + "\t\23\2\2\u0127V\3\2\2\2\u0128\u0129\t\24\2\2\u0129X\3\2\2\2\u012a\u012b"+ + "\t\25\2\2\u012bZ\3\2\2\2\u012c\u012d\t\26\2\2\u012d\\\3\2\2\2\u012e\u012f"+ + "\t\27\2\2\u012f^\3\2\2\2\u0130\u0131\t\30\2\2\u0131`\3\2\2\2\u0132\u0133"+ + "\t\31\2\2\u0133b\3\2\2\2\u0134\u0135\t\32\2\2\u0135d\3\2\2\2\u0136\u0137"+ + "\t\33\2\2\u0137f\3\2\2\2\u0138\u0139\t\34\2\2\u0139h\3\2\2\2\u013a\u013b"+ + "\t\35\2\2\u013bj\3\2\2\2\u013c\u013d\7)\2\2\u013d\u013e\3\2\2\2\u013e"+ + "\u013f\b\66\2\2\u013fl\3\2\2\2\u0140\u0141\7$\2\2\u0141\u0142\3\2\2\2"+ + "\u0142\u0143\b\67\2\2\u0143n\3\2\2\2\u0144\u0146\t\36\2\2\u0145\u0144"+ + "\3\2\2\2\u0146\u0147\3\2\2\2\u0147\u0145\3\2\2\2\u0147\u0148\3\2\2\2\u0148"+ + "p\3\2\2\2\u0149\u014b\t\37\2\2\u014a\u0149\3\2\2\2\u014b\u014c\3\2\2\2"+ + "\u014c\u014a\3\2\2\2\u014c\u014d\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u014f"+ + "\b9\2\2\u014fr\3\2\2\2\13\2\u008f\u0095\u00eb\u00f9\u0101\u0106\u0147"+ + "\u014c\3\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/vdbaan/issuefinder/filter/PredicateLexer.tokens b/src/main/java/net/vdbaan/issuefinder/filter/PredicateLexer.tokens new file mode 100644 index 0000000..6aa1d64 --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/PredicateLexer.tokens @@ -0,0 +1,42 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +LPAREN=8 +RPAREN=9 +AND=10 +OR=11 +NOT=12 +IP=13 +SCANNER=14 +PORT=15 +SERVICE=16 +RISK=17 +EXPLOITABLE=18 +DESCRIPTION=19 +PLUGIN=20 +IN=21 +LIKE=22 +BETWEEN=23 +GROUP=24 +RANGE=25 +STRING=26 +SQUOTE=27 +DQUOTE=28 +CHAR=29 +WS=30 +'=='=1 +'!='=2 +'<'=3 +'<='=4 +'>'=5 +'=>'=6 +'~='=7 +'('=8 +')'=9 +'!'=12 +'\''=27 +'"'=28 diff --git a/src/main/java/net/vdbaan/issuefinder/filter/PredicateListener.java b/src/main/java/net/vdbaan/issuefinder/filter/PredicateListener.java new file mode 100644 index 0000000..77a06a8 --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/PredicateListener.java @@ -0,0 +1,148 @@ +// Generated from C:/Users/Steven/Documents/4.Projects/IssueFinder/src/main/antlr\Predicate.g4 by ANTLR 4.7 + +package net.vdbaan.issuefinder.filter; + +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link PredicateParser}. + */ +public interface PredicateListener extends ParseTreeListener { + /** + * Enter a parse tree produced by the {@code enclosedExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterEnclosedExpr(PredicateParser.EnclosedExprContext ctx); + /** + * Exit a parse tree produced by the {@code enclosedExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitEnclosedExpr(PredicateParser.EnclosedExprContext ctx); + /** + * Enter a parse tree produced by the {@code notExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterNotExpr(PredicateParser.NotExprContext ctx); + /** + * Exit a parse tree produced by the {@code notExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitNotExpr(PredicateParser.NotExprContext ctx); + /** + * Enter a parse tree produced by the {@code range} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterRange(PredicateParser.RangeContext ctx); + /** + * Exit a parse tree produced by the {@code range} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitRange(PredicateParser.RangeContext ctx); + /** + * Enter a parse tree produced by the {@code notColumn} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterNotColumn(PredicateParser.NotColumnContext ctx); + /** + * Exit a parse tree produced by the {@code notColumn} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitNotColumn(PredicateParser.NotColumnContext ctx); + /** + * Enter a parse tree produced by the {@code orExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterOrExpr(PredicateParser.OrExprContext ctx); + /** + * Exit a parse tree produced by the {@code orExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitOrExpr(PredicateParser.OrExprContext ctx); + /** + * Enter a parse tree produced by the {@code assign} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterAssign(PredicateParser.AssignContext ctx); + /** + * Exit a parse tree produced by the {@code assign} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitAssign(PredicateParser.AssignContext ctx); + /** + * Enter a parse tree produced by the {@code group} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterGroup(PredicateParser.GroupContext ctx); + /** + * Exit a parse tree produced by the {@code group} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitGroup(PredicateParser.GroupContext ctx); + /** + * Enter a parse tree produced by the {@code andExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void enterAndExpr(PredicateParser.AndExprContext ctx); + /** + * Exit a parse tree produced by the {@code andExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + */ + void exitAndExpr(PredicateParser.AndExprContext ctx); + /** + * Enter a parse tree produced by {@link PredicateParser#column}. + * @param ctx the parse tree + */ + void enterColumn(PredicateParser.ColumnContext ctx); + /** + * Exit a parse tree produced by {@link PredicateParser#column}. + * @param ctx the parse tree + */ + void exitColumn(PredicateParser.ColumnContext ctx); + /** + * Enter a parse tree produced by {@link PredicateParser#groupOperator}. + * @param ctx the parse tree + */ + void enterGroupOperator(PredicateParser.GroupOperatorContext ctx); + /** + * Exit a parse tree produced by {@link PredicateParser#groupOperator}. + * @param ctx the parse tree + */ + void exitGroupOperator(PredicateParser.GroupOperatorContext ctx); + /** + * Enter a parse tree produced by {@link PredicateParser#rangeOperator}. + * @param ctx the parse tree + */ + void enterRangeOperator(PredicateParser.RangeOperatorContext ctx); + /** + * Exit a parse tree produced by {@link PredicateParser#rangeOperator}. + * @param ctx the parse tree + */ + void exitRangeOperator(PredicateParser.RangeOperatorContext ctx); + /** + * Enter a parse tree produced by {@link PredicateParser#operator}. + * @param ctx the parse tree + */ + void enterOperator(PredicateParser.OperatorContext ctx); + /** + * Exit a parse tree produced by {@link PredicateParser#operator}. + * @param ctx the parse tree + */ + void exitOperator(PredicateParser.OperatorContext ctx); +} \ No newline at end of file diff --git a/src/main/java/net/vdbaan/issuefinder/filter/PredicateParser.java b/src/main/java/net/vdbaan/issuefinder/filter/PredicateParser.java new file mode 100644 index 0000000..b257f6a --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/PredicateParser.java @@ -0,0 +1,665 @@ +// Generated from C:/Users/Steven/Documents/4.Projects/IssueFinder/src/main/antlr\Predicate.g4 by ANTLR 4.7 + +package net.vdbaan.issuefinder.filter; + +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class PredicateParser extends Parser { + static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, LPAREN=8, RPAREN=9, + AND=10, OR=11, NOT=12, IP=13, SCANNER=14, PORT=15, SERVICE=16, RISK=17, + EXPLOITABLE=18, DESCRIPTION=19, PLUGIN=20, IN=21, LIKE=22, BETWEEN=23, + GROUP=24, RANGE=25, STRING=26, SQUOTE=27, DQUOTE=28, CHAR=29, WS=30; + public static final int + RULE_expr = 0, RULE_column = 1, RULE_groupOperator = 2, RULE_rangeOperator = 3, + RULE_operator = 4; + public static final String[] ruleNames = { + "expr", "column", "groupOperator", "rangeOperator", "operator" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'=='", "'!='", "'<'", "'<='", "'>'", "'=>'", "'~='", "'('", "')'", + null, null, "'!'", null, null, null, null, null, null, null, null, null, + null, null, null, null, null, "'''", "'\"'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, null, null, null, null, null, null, "LPAREN", "RPAREN", "AND", + "OR", "NOT", "IP", "SCANNER", "PORT", "SERVICE", "RISK", "EXPLOITABLE", + "DESCRIPTION", "PLUGIN", "IN", "LIKE", "BETWEEN", "GROUP", "RANGE", "STRING", + "SQUOTE", "DQUOTE", "CHAR", "WS" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "Predicate.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public PredicateParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + public static class ExprContext extends ParserRuleContext { + public ExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expr; } + + public ExprContext() { } + public void copyFrom(ExprContext ctx) { + super.copyFrom(ctx); + } + } + public static class EnclosedExprContext extends ExprContext { + public TerminalNode LPAREN() { return getToken(PredicateParser.LPAREN, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode RPAREN() { return getToken(PredicateParser.RPAREN, 0); } + public EnclosedExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterEnclosedExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitEnclosedExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitEnclosedExpr(this); + else return visitor.visitChildren(this); + } + } + public static class NotExprContext extends ExprContext { + public TerminalNode NOT() { return getToken(PredicateParser.NOT, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public NotExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterNotExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitNotExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitNotExpr(this); + else return visitor.visitChildren(this); + } + } + public static class RangeContext extends ExprContext { + public ColumnContext column() { + return getRuleContext(ColumnContext.class,0); + } + public RangeOperatorContext rangeOperator() { + return getRuleContext(RangeOperatorContext.class,0); + } + public TerminalNode RANGE() { return getToken(PredicateParser.RANGE, 0); } + public RangeContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterRange(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitRange(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitRange(this); + else return visitor.visitChildren(this); + } + } + public static class NotColumnContext extends ExprContext { + public TerminalNode NOT() { return getToken(PredicateParser.NOT, 0); } + public ColumnContext column() { + return getRuleContext(ColumnContext.class,0); + } + public NotColumnContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterNotColumn(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitNotColumn(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitNotColumn(this); + else return visitor.visitChildren(this); + } + } + public static class OrExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode OR() { return getToken(PredicateParser.OR, 0); } + public OrExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterOrExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitOrExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitOrExpr(this); + else return visitor.visitChildren(this); + } + } + public static class AssignContext extends ExprContext { + public ColumnContext column() { + return getRuleContext(ColumnContext.class,0); + } + public OperatorContext operator() { + return getRuleContext(OperatorContext.class,0); + } + public TerminalNode STRING() { return getToken(PredicateParser.STRING, 0); } + public AssignContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterAssign(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitAssign(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitAssign(this); + else return visitor.visitChildren(this); + } + } + public static class GroupContext extends ExprContext { + public ColumnContext column() { + return getRuleContext(ColumnContext.class,0); + } + public GroupOperatorContext groupOperator() { + return getRuleContext(GroupOperatorContext.class,0); + } + public TerminalNode GROUP() { return getToken(PredicateParser.GROUP, 0); } + public GroupContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterGroup(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitGroup(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitGroup(this); + else return visitor.visitChildren(this); + } + } + public static class AndExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode AND() { return getToken(PredicateParser.AND, 0); } + public AndExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterAndExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitAndExpr(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitAndExpr(this); + else return visitor.visitChildren(this); + } + } + + public final ExprContext expr() throws RecognitionException { + return expr(0); + } + + private ExprContext expr(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + ExprContext _localctx = new ExprContext(_ctx, _parentState); + ExprContext _prevctx = _localctx; + int _startState = 0; + enterRecursionRule(_localctx, 0, RULE_expr, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(31); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) { + case 1: + { + _localctx = new EnclosedExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(11); + match(LPAREN); + setState(12); + expr(0); + setState(13); + match(RPAREN); + } + break; + case 2: + { + _localctx = new NotExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(15); + match(NOT); + setState(16); + expr(5); + } + break; + case 3: + { + _localctx = new AssignContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(17); + column(); + setState(18); + operator(); + setState(19); + match(STRING); + } + break; + case 4: + { + _localctx = new RangeContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(21); + column(); + setState(22); + rangeOperator(); + setState(23); + match(RANGE); + } + break; + case 5: + { + _localctx = new GroupContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(25); + column(); + setState(26); + groupOperator(); + setState(27); + match(GROUP); + } + break; + case 6: + { + _localctx = new NotColumnContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(29); + match(NOT); + setState(30); + column(); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(41); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(39); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,1,_ctx) ) { + case 1: + { + _localctx = new AndExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(33); + if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); + setState(34); + match(AND); + setState(35); + expr(9); + } + break; + case 2: + { + _localctx = new OrExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(36); + if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); + setState(37); + match(OR); + setState(38); + expr(8); + } + break; + } + } + } + setState(43); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + public static class ColumnContext extends ParserRuleContext { + public TerminalNode SCANNER() { return getToken(PredicateParser.SCANNER, 0); } + public TerminalNode IP() { return getToken(PredicateParser.IP, 0); } + public TerminalNode PORT() { return getToken(PredicateParser.PORT, 0); } + public TerminalNode SERVICE() { return getToken(PredicateParser.SERVICE, 0); } + public TerminalNode RISK() { return getToken(PredicateParser.RISK, 0); } + public TerminalNode EXPLOITABLE() { return getToken(PredicateParser.EXPLOITABLE, 0); } + public TerminalNode DESCRIPTION() { return getToken(PredicateParser.DESCRIPTION, 0); } + public TerminalNode PLUGIN() { return getToken(PredicateParser.PLUGIN, 0); } + public ColumnContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_column; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterColumn(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitColumn(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitColumn(this); + else return visitor.visitChildren(this); + } + } + + public final ColumnContext column() throws RecognitionException { + ColumnContext _localctx = new ColumnContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_column); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(44); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << IP) | (1L << SCANNER) | (1L << PORT) | (1L << SERVICE) | (1L << RISK) | (1L << EXPLOITABLE) | (1L << DESCRIPTION) | (1L << PLUGIN))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class GroupOperatorContext extends ParserRuleContext { + public TerminalNode IN() { return getToken(PredicateParser.IN, 0); } + public GroupOperatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_groupOperator; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterGroupOperator(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitGroupOperator(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitGroupOperator(this); + else return visitor.visitChildren(this); + } + } + + public final GroupOperatorContext groupOperator() throws RecognitionException { + GroupOperatorContext _localctx = new GroupOperatorContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_groupOperator); + try { + enterOuterAlt(_localctx, 1); + { + setState(46); + match(IN); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class RangeOperatorContext extends ParserRuleContext { + public TerminalNode BETWEEN() { return getToken(PredicateParser.BETWEEN, 0); } + public RangeOperatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_rangeOperator; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterRangeOperator(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitRangeOperator(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitRangeOperator(this); + else return visitor.visitChildren(this); + } + } + + public final RangeOperatorContext rangeOperator() throws RecognitionException { + RangeOperatorContext _localctx = new RangeOperatorContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_rangeOperator); + try { + enterOuterAlt(_localctx, 1); + { + setState(48); + match(BETWEEN); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class OperatorContext extends ParserRuleContext { + public TerminalNode LIKE() { return getToken(PredicateParser.LIKE, 0); } + public OperatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_operator; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).enterOperator(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof PredicateListener ) ((PredicateListener)listener).exitOperator(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof PredicateVisitor ) return ((PredicateVisitor)visitor).visitOperator(this); + else return visitor.visitChildren(this); + } + } + + public final OperatorContext operator() throws RecognitionException { + OperatorContext _localctx = new OperatorContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_operator); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(50); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__1) | (1L << T__2) | (1L << T__3) | (1L << T__4) | (1L << T__5) | (1L << T__6) | (1L << LIKE))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 0: + return expr_sempred((ExprContext)_localctx, predIndex); + } + return true; + } + private boolean expr_sempred(ExprContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 8); + case 1: + return precpred(_ctx, 7); + } + return true; + } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3 \67\4\2\t\2\4\3\t"+ + "\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2"+ + "\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\5\2\"\n\2\3\2\3\2\3\2\3\2\3\2"+ + "\3\2\7\2*\n\2\f\2\16\2-\13\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\6\2\3\2"+ + "\7\2\4\6\b\n\2\4\3\2\17\26\4\2\3\t\30\30\28\2!\3\2\2\2\4.\3\2\2\2\6\60"+ + "\3\2\2\2\b\62\3\2\2\2\n\64\3\2\2\2\f\r\b\2\1\2\r\16\7\n\2\2\16\17\5\2"+ + "\2\2\17\20\7\13\2\2\20\"\3\2\2\2\21\22\7\16\2\2\22\"\5\2\2\7\23\24\5\4"+ + "\3\2\24\25\5\n\6\2\25\26\7\34\2\2\26\"\3\2\2\2\27\30\5\4\3\2\30\31\5\b"+ + "\5\2\31\32\7\33\2\2\32\"\3\2\2\2\33\34\5\4\3\2\34\35\5\6\4\2\35\36\7\32"+ + "\2\2\36\"\3\2\2\2\37 \7\16\2\2 \"\5\4\3\2!\f\3\2\2\2!\21\3\2\2\2!\23\3"+ + "\2\2\2!\27\3\2\2\2!\33\3\2\2\2!\37\3\2\2\2\"+\3\2\2\2#$\f\n\2\2$%\7\f"+ + "\2\2%*\5\2\2\13&\'\f\t\2\2\'(\7\r\2\2(*\5\2\2\n)#\3\2\2\2)&\3\2\2\2*-"+ + "\3\2\2\2+)\3\2\2\2+,\3\2\2\2,\3\3\2\2\2-+\3\2\2\2./\t\2\2\2/\5\3\2\2\2"+ + "\60\61\7\27\2\2\61\7\3\2\2\2\62\63\7\31\2\2\63\t\3\2\2\2\64\65\t\3\2\2"+ + "\65\13\3\2\2\2\5!)+"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/vdbaan/issuefinder/filter/PredicateVisitor.java b/src/main/java/net/vdbaan/issuefinder/filter/PredicateVisitor.java new file mode 100644 index 0000000..eaa910a --- /dev/null +++ b/src/main/java/net/vdbaan/issuefinder/filter/PredicateVisitor.java @@ -0,0 +1,95 @@ +// Generated from C:/Users/Steven/Documents/4.Projects/IssueFinder/src/main/antlr\Predicate.g4 by ANTLR 4.7 + +package net.vdbaan.issuefinder.filter; + +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link PredicateParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface PredicateVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by the {@code enclosedExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEnclosedExpr(PredicateParser.EnclosedExprContext ctx); + /** + * Visit a parse tree produced by the {@code notExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNotExpr(PredicateParser.NotExprContext ctx); + /** + * Visit a parse tree produced by the {@code range} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRange(PredicateParser.RangeContext ctx); + /** + * Visit a parse tree produced by the {@code notColumn} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNotColumn(PredicateParser.NotColumnContext ctx); + /** + * Visit a parse tree produced by the {@code orExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitOrExpr(PredicateParser.OrExprContext ctx); + /** + * Visit a parse tree produced by the {@code assign} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssign(PredicateParser.AssignContext ctx); + /** + * Visit a parse tree produced by the {@code group} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGroup(PredicateParser.GroupContext ctx); + /** + * Visit a parse tree produced by the {@code andExpr} + * labeled alternative in {@link PredicateParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAndExpr(PredicateParser.AndExprContext ctx); + /** + * Visit a parse tree produced by {@link PredicateParser#column}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitColumn(PredicateParser.ColumnContext ctx); + /** + * Visit a parse tree produced by {@link PredicateParser#groupOperator}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGroupOperator(PredicateParser.GroupOperatorContext ctx); + /** + * Visit a parse tree produced by {@link PredicateParser#rangeOperator}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRangeOperator(PredicateParser.RangeOperatorContext ctx); + /** + * Visit a parse tree produced by {@link PredicateParser#operator}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitOperator(PredicateParser.OperatorContext ctx); +} \ No newline at end of file diff --git a/src/main/resources/539822430.jpg b/src/main/resources/539822430.jpg new file mode 100644 index 0000000..628c2a8 Binary files /dev/null and b/src/main/resources/539822430.jpg differ diff --git a/src/main/resources/about.fxml b/src/main/resources/about.fxml new file mode 100644 index 0000000..186b9b0 --- /dev/null +++ b/src/main/resources/about.fxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + +