
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
abstract-http-client
Advanced tools
This project is a starting template for quickly implementing a python REST api client. A concrete base class encapsulating the popular requests library is provided. Abstract base class building blocks for integrating other http libraries (such as aiohttp, etc.) are also available. The main advantage to using this base class as a starting point is to save on common boilerplate actions, which are highlighted below.
pip install abstract-http-client
from abstract_http_client.http_clients.requests_client import RequestsClient
import json
class JsonPlaceholderApiClient(RequestsClient):
def __init__(self, host):
super().__init__(host=host, use_https=True)
def get_users(self):
return self.rest_service.request_get(uri="/users").json()
def get_posts(self):
return self.rest_service.request_get("/posts").json()
def add_post(self):
return self.rest_service.request_post("/posts", data={"post": "my_post"})
if __name__ == "__main__":
api = JsonPlaceholderApiClient(host="jsonplaceholder.typicode.com")
users = api.get_users()
print(json.dumps(users[:2], indent=4))
print(f"total requests sent {api.rest_service.request_counter}")
from abstract_http_client.http_clients.requests_client import RequestsClient
class SampleAuthClient(RequestsClient):
def __init__(self, host, user, password):
super().__init__(host=host, user=user, password=password)
self.login()
def login(self):
""" sample login - getting token and storing on requests session object """
data = {"user": self.user, "password": self.password}
self.token = self.rest_service.request_put(uri="/login", json=data)
self.rest_service.session.headers.update({"Authorization": self.token})
def logout(self):
""" sample logout - invalidating token and clearing session auth header """
self.rest_service.request_delete(uri=f"/logout/{self.token}")
self.rest_service.session.headers.pop({"Authorization": self.token})
def get_stuff(self) -> dict:
""" NOTE: this is pseudocode, not real endpoint """
return self.rest_service.request_get("/stuff").json()
if __name__ == "__main__":
# Context manager will handle api logout
with SampleAuthClient(host="192.168.1.3", user="admin", password="admin") as api:
# call your api here
stuff = api.get_stuff()
# Do more stuff
FAQs
Abstract Base Class for writing Requests based Rest Api Clients
We found that abstract-http-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.