Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix security vulnerabilities #45

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.8
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Get the artifact from [Maven](http://search.maven.org/#search|ga|1|g%3A%22com.pa
<dependency>
    <groupId>com.patreon</groupId>
    <artifactId>patreon</artifactId>
    <version>0.4.2</version>
    <version>0.4.3-SNAPSHOT</version>
</dependency>
```

Expand Down
46 changes: 23 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<directory>src/main/config</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>version.properties</include>
</includes>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>version.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
Expand Down Expand Up @@ -78,7 +78,7 @@ and https://issues.apache.org/jira/browse/SUREFIRE-1588 -->

<groupId>com.patreon</groupId>
<artifactId>patreon</artifactId>
<version>0.4.2</version>
<version>0.4.3-SNAPSHOT</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Interact with the Patreon API via OAuth</description>
Expand Down Expand Up @@ -113,14 +113,14 @@ and https://issues.apache.org/jira/browse/SUREFIRE-1588 -->
</scm>

<properties>
<powermock.version>1.7.3</powermock.version>
<powermock.version>2.0.2</powermock.version>
</properties>

<dependencies>
<dependency>
<groupId>com.github.jasminb</groupId>
<artifactId>jsonapi-converter</artifactId>
<version>0.8</version>
<version>0.11</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
Expand All @@ -130,17 +130,17 @@ and https://issues.apache.org/jira/browse/SUREFIRE-1588 -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.3</version>
<version>1.15.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.3</version>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -161,7 +161,7 @@ and https://issues.apache.org/jira/browse/SUREFIRE-1588 -->
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -235,16 +235,16 @@ and https://issues.apache.org/jira/browse/SUREFIRE-1588 -->
</distributionManagement>


<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
</configuration>
</plugin>
</plugins>
</reporting>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
</configuration>
</plugin>
</plugins>
</reporting>

</project>
2 changes: 1 addition & 1 deletion src/main/java/com/patreon/resources/RequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class RequestUtil {

public InputStream request(String pathSuffix, String accessToken) throws IOException {
String prefix = BASE_URI + "/api/oauth2/api/";
String prefix = BASE_URI + "/api/oauth2/api";
URL url = new URL(prefix.concat(pathSuffix));
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Authorization", "Bearer ".concat(accessToken));
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/patreon/PatreonAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testFetchUser() throws Exception {

JSONAPIDocument<User> user = api.fetchUser();

verify(requestUtil).request(eq("current_user?include=pledges"), eq(MOCK_TOKEN));
verify(requestUtil).request(eq("/current_user?include=pledges"), eq(MOCK_TOKEN));
assertEquals("https://www.patreon.com/api/user/32187", user.getLinks().getSelf().toString());
assertEquals(5, user.get().getPledges().size());
assertEquals("corgi", user.get().getVanity());
Expand All @@ -109,7 +109,7 @@ public void testFetchUserOptionalFields() throws Exception {
verify(requestUtil).request(captor.capture(), eq(MOCK_TOKEN));

String arg = captor.getValue();
assertTrue(arg.startsWith("current_user?"));
assertTrue("should start with '/current_user?'", arg.startsWith("/current_user?"));

//Extract and decode the query params from the URL
List<NameValuePair> parsed = URLEncodedUtils.parse(arg.substring(arg.indexOf('?') + 1), Charset.forName("UTF-8"));
Expand Down Expand Up @@ -161,7 +161,7 @@ public void testFetchUserUnknownProperties() throws Exception {
);

JSONAPIDocument<User> user = api.fetchUser();
verify(requestUtil).request(eq("current_user?include=pledges"), eq(MOCK_TOKEN));
verify(requestUtil).request(eq("/current_user?include=pledges"), eq(MOCK_TOKEN));
assertEquals("https://www.patreon.com/api/user/32187", user.getLinks().getSelf().toString());
}
}