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.
The Spackle Python library provides optimized access to billing aware flags created on the Spackle platform.
See the Python API docs.
pip install -U spackle-python
In order to use Spackle, you need to configure your secret key on the spackle
module. You can find your secret key in Spackle app settings page.
import spackle
spackle.api_key = "<api key>"
pricing_table = spackle.PricingTable.retrieve("abcde123")
{
id: string
name: string
intervals: string[]
products: {
id: string
description: string
name: string
features: {
id: string
name: string
key: string
type: number
value_flag: boolean
value_limit: number | null
}[]
prices: {
month?: {
id: string
unit_amount: number
currency: string
}
year?: {
id: string
unit_amount: number
currency: string
}
}
}[]
}
Spackle uses stripe ids as references to customer features.
customer = spackle.Customer.retrieve("cus_00000000")
customer.enabled("feature_key")
customer.limit("feature_key")
A customer's current subscriptions are available on the subscriptions
property. These are valid stripe.Subscription
objects as defined in the Stripe Python library.
customer.subscriptions
There is a brief delay between when an action takes place in Stripe and when it is reflected in Spackle. To account for this, Spackle provides a waiters
module that can be used to wait for a Stripe object to be updated and replicated.
spackle.wait_for_customer("cus_00000000")
spackle.wait_for_subscription("cus_000000000", "sub_00000000")
spackle.wait_for_subscription("cus_000000000", "sub_00000000", status="active")
These will block until Spackle is updated with the latest information from Stripe or until a timeout occurs.
In production, Spackle requires a valid Stripe customer. However, that is not development environments where state needs to be controlled. As an alternative, you can use a file store to test your application with seed data.
/app/spackle.json
{
"cus_000000000": {
"features": [
{
"type": 0,
"key": "flag_feature",
"value_flag": true
},
{
"type": 1,
"key": "limit_feature",
"value_limit": 100
}
],
"subscriptions": [
{
"id": "sub_000000000",
"status": "trialing",
"quantity": 1
}
]
}
}
Then configure the file store in your application:
spackle.set_store(spackle.FileStore("/app/spackle.json"))
In production, Spackle requires a valid Stripe customer. However, that is not ideal in testing or some development environments. As an alternative, you can use an in-memory store to test your application with seed data.
spackle.set_store(spackle.MemoryStore())
spackle.get_store().set_customer_data("cus_000000000", {
"features": [
{
"type": 0,
"key": "flag_feature",
"value_flag": True,
},
{
"type": 1,
"key": "limit_feature",
"value_limit": 100,
},
],
"subscriptions": [
{
"id": "sub_000000000",
"status": "trialing",
"quantity": 1,
}
]
})
Note: The in-memory store is not thread-safe and state will reset on each application restart.
The Spackle Python library emits logs as it performs various internal tasks. You can control the verbosity of Spackle's logging a few different ways:
Set the environment variable SPACKLE_LOG to the value debug
, info
, or warn
$ export SPACKLE_LOG=debug
Set spackle.log:
import spackle
spackle.log = 'debug'
Enable it through Python's logging module:
import logging
logging.basicConfig()
logging.getLogger('spackle').setLevel(logging.DEBUG)
FAQs
Unknown package
We found that spackle-python 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.