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.
Library used only for implementors of custom listeners for ReportPortal
The latest stable version is available on PyPI:
pip install reportportal-client
Basic usage example:
import os
import subprocess
from mimetypes import guess_type
from reportportal_client import RPClient
from reportportal_client.helpers import timestamp
endpoint = "http://docker.local:8080"
project = "default"
# You can get UUID from user profile page in the ReportPortal.
api_key = "1adf271d-505f-44a8-ad71-0afbdf8c83bd"
launch_name = "Test launch"
launch_doc = "Testing logging with attachment."
client = RPClient(endpoint=endpoint, project=project,
api_key=api_key)
# Start log upload thread
client.start()
# Start launch.
launch = client.start_launch(name=launch_name,
start_time=timestamp(),
description=launch_doc)
item_id = client.start_test_item(name="Test Case",
description="First Test Case",
start_time=timestamp(),
attributes=[{"key": "key", "value": "value"},
{"value", "tag"}],
item_type="STEP",
parameters={"key1": "val1",
"key2": "val2"})
# Create text log message with INFO level.
client.log(time=timestamp(),
message="Hello World!",
level="INFO")
# Create log message with attached text output and WARN level.
client.log(time=timestamp(),
message="Too high memory usage!",
level="WARN",
attachment={
"name": "free_memory.txt",
"data": subprocess.check_output("free -h".split()),
"mime": "text/plain"
})
# Create log message with binary file, INFO level and custom mimetype.
image = "/tmp/image.png"
with open(image, "rb") as fh:
attachment = {
"name": os.path.basename(image),
"data": fh.read(),
"mime": guess_type(image)[0] or "application/octet-stream"
}
client.log(timestamp(), "Screen shot of issue.", "INFO", attachment)
client.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED")
# Finish launch.
client.finish_launch(end_time=timestamp())
# Due to async nature of the service we need to call terminate() method which
# ensures all pending requests to server are processed.
# Failure to call terminate() may result in lost data.
client.terminate()
The client uses requests
library for working with RP and the same semantics
to work with attachments (data).
To log an attachment you need to pass file content and metadata to ``
import logging
from reportportal_client import RPLogger, RPLogHandler
logging.setLoggerClass(RPLogger)
rp_logger = logging.getLogger(__name__)
rp_logger.setLevel(logging.DEBUG)
rp_logger.addHandler(RPLogHandler())
screenshot_file_path = 'path/to/file.png'
with open(screenshot_file_path, "rb") as image_file:
file_data = image_file.read()
# noinspection PyArgumentList
rp_logger.info(
"Some Text Here",
attachment={"name": "test_name_screenshot.png",
"data": file_data,
"mime": "image/png"}
)
Licensed under the Apache 2.0 license (see the LICENSE.txt file).
FAQs
Python client for ReportPortal v5.
We found that reportportal-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.