Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Middleware for applying AMP Renderer to the output of a request in Django.
Middleware for applying AMP Renderer to the output of a request in Django.
Install via PyPI:
pip install django-amp-renderer
To apply the middleware, add django_amp_renderer.middleware.AMPRenderingMiddleware
to MIDDLEWARE
in your Django settings file:
MIDDLEWARE = [
'django_amp_renderer.middleware.AMPRenderingMiddleware',
…
]
The middleware expects the variables AMP_RUNTIME_VERSION
and AMP_RUNTIME_STYLES
to be set in your Django settings file.
For AMP_RUNTIME_VERSION
, provide the current AMP runtime version number as a string (to avoid losing leading zeroes). For AMP_RUNTIME_STYLES
, provide the full contents of https://cdn.ampproject.org/v0.css.
AMP_RUNTIME_VERSION = '012007242032002'
AMP_RUNTIME_STYLES = """
html{overflow-x:hidden!important}…
""".strip()
AMPRenderer has optional comment removal and attribute trimming. Those are disabled by default; To access them, use a subclass of the middleware and set the variables to True
. They are passed along to the renderer.
class TransformingMiddleware(AMPRenderingMiddleware):
should_strip_comments = True
should_trim_attributes = True
You can apply the middleware to all requests, even non-AMP pages. The transformations will only be applied if the document contains the v0.js script (https://cdn.ampproject.org/v0.js
).
If the transformation is applied, the Boilerplate-Status
header of the response will either be set to "Removed" or "Ignored", based on whether the boilerplate was able to be removed by the renderer.
Install development requirements:
make install
Sort imports (Requires Python >= 3.6):
make format
Lint (Requires Python >= 3.6):
make lint
Test:
make test
FAQs
Middleware for applying AMP Renderer to the output of a request in Django.
We found that django-amp-renderer 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.