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.
A set of Python utilities, recipes and snippets.
This utility is a decorator that iterate by each sqs record.
For each sqs record will be inserted a record object (from type sqs.Record) as argument that will process the sqs messages.
from serpens import sqs
@sqs.handler
def message_processor(record: sqs.Record):
# code to process each sqs message
print(record.body)
class Record:
data: Dict[Any, Any]
body: Union[dict, str]
message_attributes: Dict[Any, Any]
queue_name: str
sent_datetime: datetime
data["body"]
converted to dict
or str
.data["messageAttributes"]
converted to dict
.data["eventSourceARN"]
.data["attributes"]["SentTimestamp"]
converted to datetime
.api.handler
will decorate a function that will process a lambda and this function will receive a request
argument (from type api.Request).from serpens import api
@api.handler
def lambda_handler(request: api.Request):
# Code to process the lambda
print(request.body)
from serpens.api import AttrDict
class Request:
authorizer: AttrDict
body: Union[str, dict]
path: AttrDict
query: AttrDict
headers: AttrDict
identity: AttrDict
AttrDict
are objects built by a dict where the dict's key is an attribute of object. For example:from serpens.api import AttrDict
obj = AttrDict({"foo": "bar"})
obj.foo # bar
- Static type check
- Method to convert an object to dict
- Method to create an object from json
- Method to create an object from dict
- Method to dump an object to string
from serpens.schema import Schema
from dataclasses import dataclass
@dataclass
class PersonSchema(Schema):
name: str
age: int
person = PersonSchema('Mike', 30)
print(person.name)
print(person.age)
person_obj = PersonSchema.load({'name': 'Mike', 'age': 18})
print(person_obj.name)
print(person_obj.age)
import json
data = json.dumps({'name': 'mike', 'age': 20})
person_obj = PersonSchema.loads(data)
print(person_obj.name)
print(person_obj.age)
p1 = PersonSchema('Mike', 30)
person_dct = PersonSchema.dump(p1)
print(person_dct['name'])
print(person_dct['age'])
p1 = PersonSchema('Mike', 30)
person_str = PersonSchema.dumps(p1)
print(person_str)
from serpens import csvutils as csv
dict_reader = csv.open_csv_reader('fruits_iso8859.csv')
for record in dict_reader:
print(record)
from serpens import csvutils as csv
writer = csv.open_csv_writer('out.csv')
writer.writerow(["id", "name"])
writer.writerow(["1", "Açaí"])
del writer
This utilities are useful for working with database.
from serpens import database
database_url = "postgres://user:password@host/db"
path = "/path/to/migrations" # yoyo migrations
database.migrate(database_url, path)
"The Database object manages database connections using a connection pool."
from serpens import database
database_url = "postgres://user:password@host/db"
db = database.setup(database_url)
print(db.provider_name)
Serpens provides a base class (called BaseDocument) for working with tables from DynamoDB.
from serpens.document import BaseDocument
from dataclasses import dataclass
@dataclass
class PersonDocument(BaseDocument):
_table_name_ = 'person'
id: str
name: str
person = PersonDocument(id="1", name="Ana")
person.save()
None
person = PersonDocument.get_by_key({"id": "1"})
person.id # 1
person.name # Ana
person_table = PersonDocument.get_table()
person_table # dynamodb.Table(name='person')
FAQs
A set of Python utilities, recipes and snippets
We found that noverde-serpens 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.
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.