-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into autoscaling-limits
- Loading branch information
Showing
7 changed files
with
133 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/com/conveyal/analysis/controllers/ArgumentValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.conveyal.analysis.controllers; | ||
|
||
import com.conveyal.analysis.components.broker.Broker; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* Tests that check how parameters received over the HTTP API are validated. | ||
* These validators should be fairly strict about what they accept, and should not tolerate the presence of things | ||
* like semicolons or double dashes that indicate attempts to corrupt or gain access to database contents. | ||
* | ||
* Arguably we should have another layer of input sanitization that not only refuses but logs anything that contains | ||
* characters or substrings that could be associated with an attempted attack, and that same validator should be | ||
* applied to every input (perhaps called from every other input validator). | ||
*/ | ||
public class ArgumentValidationTest { | ||
|
||
@Test | ||
void testIdValidation () { | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
BrokerController.checkIdParameter("hello", "param"); | ||
}); | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
BrokerController.checkIdParameter("Robert'); DROP TABLE Students;--", "param"); | ||
// https://xkcd.com/327/ | ||
}); | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
BrokerController.checkIdParameter("0123456789012345", "param"); | ||
}); | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
BrokerController.checkIdParameter("0123456789ABCDEF67890ZZZZ5678901", "param"); | ||
}); | ||
Assertions.assertDoesNotThrow(() -> { | ||
BrokerController.checkIdParameter("0123456789abcDEF6789012345678901", "param"); | ||
}); | ||
Assertions.assertDoesNotThrow(() -> { | ||
String validUuid = UUID.randomUUID().toString(); | ||
BrokerController.checkIdParameter(validUuid, "param"); | ||
}); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
src/test/resources/com/conveyal/r5/streets/missing-nodes.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<osm version="0.6"> | ||
<bounds minlat="54.0889580" minlon="12.2487570" maxlat="54.0913900" maxlon="12.2524800"/> | ||
<node id="261728686" lat="54.0906309" lon="12.2441924" user="PikoWinter" uid="36744" visible="true" version="1" changeset="323878" timestamp="2008-05-03T13:39:23Z"/> | ||
<node id="298884269" lat="54.0901746" lon="12.2482632" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/> | ||
<node id="298884272" lat="54.0901447" lon="12.2516513" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/> | ||
<node id="1831881213" version="1" changeset="12370172" lat="54.0900666" lon="12.2539381" user="lafkor" uid="75625" visible="true" timestamp="2012-07-20T09:43:19Z"> | ||
<tag k="name" v="Neu Broderstorf"/> | ||
<tag k="traffic_sign" v="city_limit"/> | ||
</node> | ||
<way id="14"> | ||
<nd ref="298884269"/> | ||
<nd ref="261728686"/> | ||
<tag k="name" v="Fake Test Straße"/> | ||
</way> | ||
<way id="26659127" user="Masch" uid="55988" visible="true" version="5" changeset="4142606" timestamp="2010-03-16T11:47:08Z"> | ||
<nd ref="1831881213"/> | ||
<nd ref="298884272"/> | ||
<nd ref="298884269"/> | ||
<nd ref="42"/> | ||
<nd ref="261728686"/> | ||
<tag k="highway" v="unclassified"/> | ||
<tag k="name" v="Pastower Straße"/> | ||
</way> | ||
</osm> |