Skip to content

Commit 50d2ad0

Browse files
committed
Add SWAN plugin directory
2 parents 2d1fc61 + a5600ac commit 50d2ad0

File tree

182 files changed

+9713
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+9713
-0
lines changed

.gitignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Created by https://www.gitignore.io/api/java,maven,intellij
2+
3+
### Intellij ###
4+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
5+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
6+
7+
# User-specific stuff:
8+
.idea/**/workspace.xml
9+
.idea/**/tasks.xml
10+
.idea/dictionaries
11+
12+
# Sensitive or high-churn files:
13+
.idea/**/dataSources/
14+
.idea/**/dataSources.ids
15+
.idea/**/dataSources.xml
16+
.idea/**/dataSources.local.xml
17+
.idea/**/sqlDataSources.xml
18+
.idea/**/dynamic.xml
19+
.idea/**/uiDesigner.xml
20+
21+
# Gradle:
22+
.idea/**/gradle.xml
23+
.idea/**/libraries
24+
25+
# CMake
26+
cmake-build-debug/
27+
28+
# Mongo Explorer plugin:
29+
.idea/**/mongoSettings.xml
30+
31+
## File-based project format:
32+
*.iws
33+
34+
## Plugin-specific files:
35+
36+
# IntelliJ
37+
/out/
38+
/.idea/
39+
40+
# mpeltonen/sbt-idea plugin
41+
.idea_modules/
42+
43+
# JIRA plugin
44+
atlassian-ide-plugin.xml
45+
46+
# Cursive Clojure plugin
47+
.idea/replstate.xml
48+
49+
# Ruby plugin and RubyMine
50+
/.rakeTasks
51+
52+
# Crashlytics plugin (for Android Studio and IntelliJ)
53+
com_crashlytics_export_strings.xml
54+
crashlytics.properties
55+
crashlytics-build.properties
56+
fabric.properties
57+
58+
### Intellij Patch ###
59+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
60+
61+
*.iml
62+
# modules.xml
63+
# .idea/misc.xml
64+
# *.ipr
65+
66+
# Sonarlint plugin
67+
.idea/sonarlint
68+
69+
### Java ###
70+
# Compiled class file
71+
*.class
72+
73+
# Log file
74+
*.log
75+
76+
# BlueJ files
77+
*.ctxt
78+
79+
# Mobile Tools for Java (J2ME)
80+
.mtj.tmp/
81+
82+
# Package Files #
83+
*.war
84+
*.ear
85+
*.zip
86+
*.tar.gz
87+
*.rar
88+
89+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
90+
hs_err_pid*
91+
92+
### Maven ###
93+
target/
94+
pom.xml.tag
95+
pom.xml.releaseBackup
96+
pom.xml.versionsBackup
97+
pom.xml.next
98+
release.properties
99+
dependency-reduced-pom.xml
100+
buildNumber.properties
101+
.mvn/timing.properties
102+
103+
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
104+
!/.mvn/wrapper/maven-wrapper.jar
105+
106+
# End of https://www.gitignore.io/api/java,maven,intellij

swan_assist/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2018, Fraunhofer IEM
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

swan_assist/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SWAN_Assist
2+
IntelliJ IDEA Plug-in for the Security methods for WeAkNess detection (SWAN) tool.
3+
4+
Description:
5+
-------------
6+
SWAN is a machine-learning approach for detection of methods of interest for security in Java libraries.
7+
SWAN should be used in combination with other static analyses tools. It helps the users to create a set of relevant methods required as an input for static analyses, e.g. taint- and type-state analysis.
8+
SWAN detects four types of methods: source, sink, sanitizer, and authentication method.
9+
The found methods are further cathegorized according to relevant vulnerabilities (Common Weakness Enummeration - CWE). Curretntly SWAN supports the following CWEs: CWE89, CWE79, CWE306, CWE862, and CWE863.
10+
11+
SWAN_Assist provides a GUI support for SWAN. The user is able to interact with the learning process by giving feedback on the methods of interest.
12+
The tool helps users that write static analyses to create list of SWAN for their specific Java libraries.
13+
Moreover, users can manually inspect the proper usage of the methods detected by SWAN.
14+
15+
Contributors:
16+
* Goran Piskachev (goran.piskachev@iem.fraunhofer.de)
17+
* Oshando Johnson (oshando@campus.uni-paderborn.de)
18+
* Lisa Nguyen (lisa.nguyen@uni-paderborn.de)
19+
20+
## Setting Up the Plugin
21+
22+
Import the project using either of the following methods:
23+
##### Cloning Project from the Repository
24+
1) Select the *File>Project from Version Control>Git* option, enter the repository’s URL and then select *Clone* to import the project.
25+
2) Go to *File>Project Structure* to edit the project settings.
26+
3) For the project's SDK, select the *IntelliJ IDEA IU-** option.
27+
4) Select *Modules* from the left panel and use the *Add* button to add a new project module. In the window that appears, select *IntelliJ Platform Plugin* from the left panel and select *OK*. Select a name for the module and ensure that the *Content Root* and *Module File Location* point to the project's root folder and select *Finish*. If a default module was generated while importing the project, you can remove it.
28+
5) Select Libraries from the left panel, select the *Add* button and select Java. Select the ``/libs`` folder in the window that appears and select *Open*.
29+
30+
##### Downloading and Importing Project
31+
1) Download the project from Github and then use the *File>Project from Existing Resources* from the menu to import the project. Select the downloaded project's root folder and select *Open*.
32+
2) Select the option to *Create Project from existing sources* and then proceed.
33+
3) At the step to select the project's source files, deselect the ``test-project/src`` entry, if it was automatically selected. The project libraries will be automatically detected and a module will also be created.
34+
4) Validate that the project was imported correctly and the module was correctly created. If there are issues, follow the steps in step 2 in the above section.
35+
36+
## Running the Plugin
37+
To run the plugin, select the *Run Configuration* drop down menu and select *Edit Configurations*. Ensure that the module that was created previously is selected and press Ok. You should now be able to run the project.
38+
39+
A separate instance of IntelliJ will be launched. Use the open option to select the project found in ``/example-project`` directory. You may need to setup a project SDK for the project if one isn’t automatically configured. You should then be able to run the test project.
40+
41+
Logs for the plugin will appear in the initial instance of IntelliJ.
42+
43+
## Building the Plugin
44+
To build the plugin, select the "Prepare Plugin Module '...' For Deployment" option from the Build menu. This will generate the a zip file that contains the plugin's jars and resources in the project's root directory.
45+
46+
## Installing the Plugin
47+
To install the plugin, go Preferences and select "Plugins" from the sidebar. Select the "Install Plugin from disk" button, locate the plugin file and select it. You will need to restart IntelliJ for the plugin to work.
48+
49+
Contact:
50+
-------------
51+
Goran Piskachev (Fraunhofer IEM, Zukunftsmeile 1, 33102 Paderborn, Office: 02-13)

swan_assist/docs/Feature List.docx

24.4 KB
Binary file not shown.
3.76 MB
Binary file not shown.
402 KB
Binary file not shown.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package de.fraunhofer.iem.swan.example;
2+
3+
import java.io.IOException;
4+
5+
import javax.servlet.ServletException;
6+
import javax.servlet.http.HttpServletRequest;
7+
import javax.servlet.http.HttpServletResponse;
8+
import javax.servlet.http.HttpServletResponseWrapper;
9+
import com.mysql.jdbc.Connection;
10+
import com.mysql.jdbc.ResultSet;
11+
import com.mysql.jdbc.Statement;
12+
13+
14+
public class ExampleSQLiOpenRedirect {
15+
16+
private Connection conn;
17+
18+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
19+
throws ServletException, IOException {
20+
21+
try {
22+
String userId = request.getParameter("userId");
23+
userId = encode(userId);
24+
25+
Statement st = (Statement) conn.createStatement();
26+
String query = "SELECT * FROM User WHERE userId=’" + userId + "’;";
27+
ResultSet res = (ResultSet) st.executeQuery(query);
28+
String url = "https://" + userId + ".company.com";
29+
response.sendRedirect(url);
30+
} catch (Exception e) {
31+
}
32+
33+
}
34+
35+
private String encode(String userId) {
36+
HttpServletResponseWrapper encoder = new HttpServletResponseWrapper(null);
37+
String result = encoder.encodeRedirectURL(userId);
38+
return result;
39+
}
40+
}
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package de.fraunhofer.iem.swan.example.api;
2+
3+
import de.fraunhofer.iem.swan.example.api.comm.EmailClient;
4+
import de.fraunhofer.iem.swan.example.api.data.Customer;
5+
import de.fraunhofer.iem.swan.example.api.data.TravelOffer;
6+
import de.fraunhofer.iem.swan.example.api.util.UserManagement;
7+
8+
public class TravelWishlist {
9+
10+
public static void main(String[] args) {
11+
12+
//create new customer
13+
Customer customer = new Customer("Daniel Bruns", "1454876798761237", 3456.89);
14+
15+
//set password and email
16+
customer.setPassword("password");
17+
customer.setEmail("daniel.bruns@gmail.com");
18+
19+
//send confirmation email
20+
EmailClient confirmationEmail = new EmailClient();
21+
22+
String []addresses = new String[]{customer.getEmail(), "user@verification@travelwishlist.com"};
23+
String subject = "Account Confirmation";
24+
String emailBody = "Hello " + customer.getName() + ", \nPlease confirm your email and credit card details. " + UserManagement.maskCreditCard(customer.getCreditCard());
25+
26+
if(confirmationEmail.sendEmail(addresses, subject, emailBody))
27+
System.out.println("Account verification e-mail was successfully sent.");
28+
else
29+
System.out.println("An error occured.");
30+
31+
TravelOffer offer = new TravelOffer();
32+
}
33+
34+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package de.fraunhofer.iem.swan.example.api.comm;
2+
3+
public class EmailClient {
4+
5+
public boolean sendEmail(String [] addresses, String subject, String body){
6+
7+
return true;
8+
}
9+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package de.fraunhofer.iem.swan.example.api.data;
2+
3+
import de.fraunhofer.iem.swan.example.api.util.UserManagement;
4+
5+
public class Customer {
6+
7+
private String name;
8+
String creditCard;
9+
String password;
10+
String email;
11+
double budget;
12+
13+
14+
public Customer(String customerName, String creditCard, double budget) {
15+
16+
setName(customerName);
17+
setCreditCard(creditCard);
18+
setBudget(budget);
19+
}
20+
21+
public String getPassword() {
22+
return password;
23+
}
24+
25+
public void setPassword(String password) {
26+
this.password = UserManagement.hashPassword(password, "SHA-256");
27+
}
28+
29+
public String getEmail() {
30+
return email;
31+
}
32+
33+
public void setEmail(String email) {
34+
if (UserManagement.validateEmail(email))
35+
this.email = email;
36+
}
37+
38+
public String getName() {
39+
return name;
40+
}
41+
42+
public void setName(String name) {
43+
this.name = name;
44+
}
45+
46+
public String getCreditCard() {
47+
return creditCard;
48+
}
49+
50+
public void setCreditCard(String creditCard) {
51+
this.creditCard = creditCard;
52+
}
53+
54+
public double getBudget() {
55+
return budget;
56+
}
57+
58+
public void setBudget(double budget) {
59+
this.budget = budget;
60+
}
61+
62+
63+
}

0 commit comments

Comments
 (0)