Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
org.mikeneck.httpspec:http-spec-runner
Advanced tools
Testing library for http API with DSL and jsonpath assertion.
http-spec is a library for web services to describe REST API specification.
This library build on top of Java 11's http API.
spec:
- name: 'getting path resource with paging parameters'
request:
get: 'http://localhost:8080/path'
queries:
q: test
page: 4
limit: 10
headers:
accept: application/json
authorization: bearer 11aa22bb33cc
response:
status: 200
headers:
content-type: application/json
body:
- path: $.firstName
expect:
type: string
value: John
class RestApiTest {
@Test
void runRequestFromYamlFile() {
var yamlFile = new File("/path/to/spec.yaml");
HttpSpecRunner.from(yamlFile).run(); // runs all requests and asserts responses.
}
}
class RestApiTest {
@Test
void runRequestByJavaCode() {
HttpSpecRunner.Builder builder = HttpSpecRunner.builder();
builder.addSpec(spec -> {
spec.name("getting path resource with paging parameters");
spec.request().get("http://localhost:8080/path", request -> {
request.query("q", "test");
request.query("page", 4);
request.query("limit", 10);
request.header("accept", "application/json");
request.header("authorization", "bearer 11aa22bb33cc");
});
spec.response(response -> {
response.status(200);
response.header("content-type", "application/json");
response.jsonBody(jsonBody -> jsonBody.path("$.firstName").toBe("John"));
});
});
HttpSpecRunner httpSpecRunner = builder.build();
httpSpecRunner.run(); // runs all requests and asserts responses.
}
}
T.B.D.
With junit-jupiter module, you can convert HttpSpecRunner
into Stream<DynamicTest>
.
import java.util.stream.Stream;
class RestApiTest {
// With junit-jupiter module, you can use httpSpecRunner as dynamic tests.
@TestFactory
Stream<DynamicTest> asDynamicTests() {
HttpSpecRunner.Builder builder = HttpSpecRunner.builder();
// same as the code in runRequestByJavaCode
HttpSpecRunner httpSpecRunner = builder.build();
// converts each assertion to dynamicTest
// - http status to be 200
// - content-type header to be application/json
// - body json has element $.firstName to be John
return DynamicTestAdapter.adapt(httpSpecRunner);
}
}
FAQs
Unknown package
We found that org.mikeneck.httpspec:http-spec-runner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.