Skip to content

beaglesecurity/beagle-java-sdk

Repository files navigation

Logo

Developer guide for Beagle Security SDK

This library can be used to automate penetration testing of your website using Beagle Security

Maven Central

Table of Contents

Getting Started

Beagle Security is a web application & API penetration testing tool that helps you to identify vulnerabilities on your website before hackers exploit them. There are two mechanisms available for automating the process.

  • Using REST APIs
  • Using SDK

You can find the complete set of REST APIs in the Beagle Security API documentation page.

Adding Beagle Security SDK as a Maven Dependency

Maven:

<dependencies>
    <dependency>
        <groupId>com.beaglesecurity</groupId>
        <artifactId>beagle-java-sdk</artifactId>
        <version>1.2</version>
    </dependency>
</dependencies>

Basic Usage

Once you have resolved the dependencies, you can start using the SDK by creating BeagleSecurityClient to communicate with the Beagle Security platform. The below code will fetch all the projects available under a user.

public static void main(String[] args) throws IOException {
   // Beagle Security client for communicating with platform
	BeagleSecurityClient client= 
			BeagleSecurityClientBuilder.instance()
			// This token will be generated from beagle security settings->Access Token
			.withAPIToken("j69czobljo3ozp2knze4v1554eekp3r9")
			.build();
	// Gets all the projects and its applications under a user 
	List<ProjectWithApplication> projects = client.getAllProjects();
}

Starting a test

The below code snippet can be used to trigger a new penetration test.

public static void main(String[] args) throws IOException {
   // Beagle Security client for communicating with platform
	BeagleSecurityClient client= 
			BeagleSecurityClientBuilder.instance()
			// This token will be generated from beagle security settings->Access Token
			.withAPIToken("j69czobljo3ozp2knze4v1554eekp3r9")
			.build();
	// The application token will be available in the application settings page
	String applicationToken = "6mkakhiyhxlonol42v87e9cs2gbyarpg";
	// Start a test
	StartTest startTestResult = client.startTest(applicationToken);
	// If started, return a result token
	System.out.println(startTestResult.getResultToken());
}

Getting status of a running test

The below code snippet can be used to get the status of a running test.

public static void main(String[] args) throws IOException {
   // Beagle Security client for communicating with platform
	BeagleSecurityClient client= 
			BeagleSecurityClientBuilder.instance()
			// This token will be generated from beagle security settings->Access Token
			.withAPIToken("j69czobljo3ozp2knze4v1554eekp3r9")
			.build();
	// The application token will be available in the application settings page
	String applicationToken = "6mkakhiyhxlonol42v87e9cs2gbyarpg";
	// This will be available from the start test API or getTestSessions() or 
	// getTestRunningSessions() APIs
	String resultToken = "wagywiof6m76j1jwgzt8wgjtkuhiuxnv";
	// Start a test
	TestStatus testStatus = client.getTestStatus(applicationToken, resultToken);
	System.out.println("Test Status : " + testStatus.getStatus());
	System.out.println("Test Progress : " + testStatus.getProgress());
}

Getting test result json

The below code snippet can be used to get the test result once a penetration test is completed.

public static void main(String[] args) throws IOException {
   // Beagle Security client for communicating with platform
	BeagleSecurityClient client= 
			BeagleSecurityClientBuilder.instance()
			// This token will be generated from beagle security settings->Access Token
			.withAPIToken("j69czobljo3ozp2knze4v1554eekp3r9")
			.build();
	// The application token will be available in the application settings page
	String applicationToken = "6mkakhiyhxlonol42v87e9cs2gbyarpg";
	// This will be available from the start test API or getTestSessions() or 
	// getTestRunningSessions() APIs
	String resultToken = "wagywiof6m76j1jwgzt8wgjtkuhiuxnv";
	// Gets the test result
	String jsonResult = client.getTestResultJson(applicationToken, resultToken);
}

License

This library is Licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages