Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Micro-Framwork for gRPC with REST expose support.
pip install cygrpc
git+https://github.com/cuemby/python-cygrpc.git#egg=cygrpc
Params:
if you decide used all values by default, you can setup the server in less lines
from cygrpc.server import Server
server = Server()
server.add_service(calculator_api_pb2_grpc, ServiceImpl)
server.start()
Example using all params:
from cygrpc.server import Server
# Initialization of server definition, 'host', 'port', 'max_threads' has be optionals.
# By default the __init__ function set the same values. if don't you wanna set interceptors only remove the param
server = Server(host="0.0.0.0", port=50051, max_threads=10, interceptors=(MyAuthInterceptor(),))
# attach service to server, repeat for multiple services
server.add_service(calculator_api_pb2_grpc, ServiceImpl)
# finally start server.
server.start()
The implementation is the same.
# import rest decorator
from cygrpc.gateway.http import rest
class ServiceImpl(calculator_api_pb2_grpc.CalculatorAPIServicer):
"""
Service logic implementation.
"""
def Sum(self, request, context):
total = 0
for addend in request.addends:
total += addend
response = pb.SumResponse(sum=total)
return response
for add rest route add the decorator @rest to method definition:
# import rest decorator
from cygrpc.gateway.http import rest
class ServiceImpl(calculator_api_pb2_grpc.CalculatorAPIServicer):
"""
Service logic implementation.
"""
@rest("/v1/calculator/sum", method="POST")
def Sum(self, request, context):
total = 0
for addend in request.addends:
total += addend
response = pb.SumResponse(sum=total)
return response
from cygrpc.middleware import CyGrpcInterceptor
class CustomInterceptor(CyGrpcInterceptor):
def intercept_service(self, continuation, handler_call_details):
# for continue to method implementation
return self.on_success(continuation, handler_call_details)
# for terminate request
return self.on_failed(grpc.StatusCode.UNAUTHENTICATED, "Validate authentication failed.")
from cygrpc.middleware.auth import CyGrpcAuthInterceptor
class MyAuthInterceptor(CyGrpcAuthInterceptor):
def auth_process(self, continuation, handler_call_details):
""""
..... my auth validation process ....
"""
return True
FAQs
gRPC Micro framework
We found that cygrpc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.