Skip to content

tailmonsec/jdbaudit-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jdbaudit-java

jDBAudit Java Implementation.

Installing

Maven

<dependency>
    <groupId>com.jthinking.jdbaudit</groupId>
    <artifactId>jdbaudit</artifactId>
    <version>0.1.0</version>
</dependency>

Gradle

implementation 'com.jthinking.jdbaudit:jdbaudit:0.1.0'

Usage

RiskScanner riskScanner = new RiskScanner();

// load rules
try (FileInputStream inputStream = new FileInputStream("jdbaudit-rules/AUDIT.json")) {
    String jsonRule = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
    riskScanner.loadRule(jsonRule, false);
}

// create DBSettings
DBSettings dbSettings = new MySQLSettings("localhost", 3306, "root", "root");

// submit task
riskScanner.submitTask(ScanTask.of(dbSettings, RiskType.AUDIT, new ScanTaskHandler() {

    @Override
    public void onStart(ScanTask scanTask) {
        System.out.println("onStart:" + scanTask.getTaskId());
    }

    @Override
    public void onAlert(ScanTask scanTask, ScanResult result) {
        Alert alert = result.getAlert();
        Rule rule = alert.getRule();
        String data = alert.getData();
        String taskId = scanTask.getTaskId();
        System.out.println("onAlert:" + scanTask.getTaskId());
    }

    @Override
    public void onFinish(ScanTask scanTask) {
        System.out.println("onFinish:" + scanTask.getTaskId());
    }

    @Override
    public void onError(ScanTask scanTask, Throwable error) {
        System.out.println("onError:" + scanTask.getTaskId());
    }
}));

// waiting for async task finish
Thread.sleep(1000 * 60);

// stop scanner
riskScanner.stop();

About

jDBAudit Pure Java implementation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published