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.
com.github.balchua:gire-mock
Advanced tools
A utility to help create a gRPC mock server which utilizes WireMock for handling mock requests.
A gRPC mock server which utilizes WireMock for handling mock requests.
gireMock utilizes the excellent project from salesforce - jProtoc to generate code as part of protobuf maven plugin code gen and Wiremock to serve mock requests back to gRPC clients.
gireMock
If you are using Maven, follow the instruction below.
<dependency>
<groupId>io.bal.tools.grpc</groupId>
<artifactId>gire-mock</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
gireMock
to the protoPlugin
section of the protobuf-maven-plugin
<execution><configuration>
section.Sample below.
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.6.1:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
<configuration>
<protocPlugins>
<protocPlugin>
<id>java8</id>
<groupId>io.bal.tools.grpc</groupId>
<artifactId>gire-mock</artifactId>
<version>1.0-SNAPSHOT</version>
<mainClass>io.giremock.generator.mock.MockGenerator</mainClass>
</protocPlugin>
</protocPlugins>
</configuration>
</execution>
</executions>
</plugin>
All classes generated will have these classes:
<GRPC service name>Mockery.class
<GRPC service name>Mock.class
For example the following gRPC service definition
service PersonManagement {
rpc GetPersonById (PersonById) returns (Person) {
}
rpc randomNames (google.protobuf.Empty) returns (Person) {
}
rpc whatsTheNameInTheFile (google.protobuf.Empty) returns (FileContent) {
}
}
The generated classes will be:
PersonManagementMockery.PersonManagementMock
Since all the generated codes are part of your project, you can easily start your gRPC server like below.
Arguments to the Mock Services are Wiremock host and port.
Server server = ServerBuilder.forPort(port).
addService(new PersonManagementMockery.PersonManagementMock("localhost",5501)).
build();
server.start();
. . .
server.awaitTermination();
java -jar wiremock-standalone-2.20.0.jar --port 5501
If you have Grpc method (GetPersonById
)
You should define your request.url
to be /getPersonById
The response body must adhere to the Message returned by the method.
{
"request": {
"method": "POST",
"url": "/getPersonById",
"bodyPatterns" : [ {
"equalToJson" : "{ \"id\": 4 }"
} ]
},
"response": {
"status": 200,
"body": "{ 'id' : '123', 'firstName' : 'ultimate', 'lastName' : 'warrior', 'description' : 'Wrestler'}"
}
}
See grpcdomain project repo.
Limitations:
FAQs
A utility to help create a gRPC mock server which utilizes WireMock for handling mock requests.
We found that com.github.balchua:gire-mock 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.