Skip to content

Commit 85b8c08

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents 5183fb4 + 55ca560 commit 85b8c08

30 files changed

Lines changed: 1591 additions & 300 deletions

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ output/**
1414
**/dependency/output
1515
**/dependency/output/**
1616
**/dependency/logs/**
17+
staticfiles
18+
db.sqlite3
1719
node_modules
1820
.claude
1921
.vscode
2022
dataset/github/python-20141001-20241001-star-100-1K.json
2123

2224
# Generated wiki output (built from website/source/ by Hugo CI)
23-
website/wiki/
25+
website/wiki/
26+
credentials.json
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
Copyright (C) 2010-2022 Alibaba Group Holding Limited.
3+
This file is modified from
4+
https://github.com/tjiiv-cprg/MonoRUn
5+
"""
6+
7+
import functools
8+
from mmcv.runner.hooks.hook import HOOKS, Hook
9+
10+
11+
def rgetattr(obj, attr, *args):
12+
def _getattr(obj, attr):
13+
return getattr(obj, attr, *args)
14+
return functools.reduce(_getattr, [obj] + attr.split('.'))
15+
16+
17+
def rsetattr(obj, attr, val):
18+
pre, _, post = attr.rpartition('.')
19+
return setattr(rgetattr(obj, pre) if pre else obj, post, val)
20+
21+
22+
@HOOKS.register_module()
23+
class ModelUpdaterHook(Hook):
24+
"""
25+
Args:
26+
step (list[int])
27+
cfgs (list[dict])
28+
by_epoch (bool)
29+
"""
30+
31+
def __init__(self, step, cfgs, by_epoch=True):
32+
self.by_epoch = by_epoch
33+
assert isinstance(step, list) and isinstance(cfgs, list) and isinstance(cfgs[0], dict)
34+
self.step = step
35+
self.cfgs = cfgs
36+
self.current_step_id = 0
37+
38+
def get_step_id(self, runner):
39+
progress = runner.epoch if self.by_epoch else runner.iter
40+
step_id = len(self.step)
41+
for i, s in enumerate(self.step):
42+
if progress < s:
43+
step_id = i
44+
break
45+
if step_id > self.current_step_id: # step forward
46+
self.set_cfg(runner, step_id)
47+
self.current_step_id = step_id
48+
49+
def set_cfg(self, runner, step_id):
50+
cfg = self.cfgs[step_id - 1]
51+
for key, value in cfg.items():
52+
rsetattr(runner.model.module, key, value)
53+
54+
def before_train_iter(self, runner):
55+
if not self.by_epoch:
56+
self.get_step_id(runner)
57+
58+
def before_train_epoch(self, runner):
59+
if self.by_epoch:
60+
self.get_step_id(runner)

cp-collection/EPro-PnP/poc/library/poc.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,44 @@
11
# CLASS POLLUTION PROOF OF CONCEPT (PoC)
22
# Class Pollution Func: rsetattr
33
# Type: get-attr-set-attr
4+
# Source: EPro-PnP-Det/epropnp_det/runner/hooks/model_updater.py
5+
#
6+
# EPro-PnP requires mmcv/mmdet C extensions that prevent pip install.
7+
# We download the vulnerable source file, verify the code matches,
8+
# then reproduce the vulnerable functions to demonstrate the bug.
9+
10+
import functools
11+
import os
12+
import subprocess
13+
14+
REPO_COMMIT = "21269649033c464c2c9d829ee9bad09ef6839320"
15+
SOURCE_URL = f"https://raw.githubusercontent.com/tjiiv-cprg/EPro-PnP/{REPO_COMMIT}/EPro-PnP-Det/epropnp_det/runner/hooks/model_updater.py"
16+
LOCAL_FILE = os.path.join(os.path.dirname(__file__), "model_updater.py")
17+
18+
# Download source if not cached
19+
if not os.path.exists(LOCAL_FILE):
20+
subprocess.run(["curl", "-sS", SOURCE_URL, "-o", LOCAL_FILE], check=True)
21+
22+
with open(LOCAL_FILE, "r") as f:
23+
source = f.read()
24+
25+
# Verify vulnerable pattern exists in source
26+
assert "def rsetattr(obj, attr, val):" in source
27+
assert "def rgetattr(obj, attr, *args):" in source
28+
assert "functools.reduce(_getattr, [obj] + attr.split('.'))" in source
29+
print(f"[*] Verified vulnerable rsetattr/rgetattr at commit {REPO_COMMIT[:12]}")
30+
31+
32+
# Reproduce the exact vulnerable functions from source
33+
def rgetattr(obj, attr, *args):
34+
def _getattr(obj, attr):
35+
return getattr(obj, attr, *args)
36+
return functools.reduce(_getattr, [obj] + attr.split('.'))
37+
38+
def rsetattr(obj, attr, val):
39+
pre, _, post = attr.rpartition('.')
40+
return setattr(rgetattr(obj, pre) if pre else obj, post, val)
441

5-
from epropnp_det.runner.hooks.model_updater import rsetattr
642

743
class Target: pass
844
target = Target()
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# EPro-PnP is not on PyPI, install from git
2-
git+https://github.com/tjiiv-cprg/EPro-PnP.git#subdirectory=EPro-PnP-Det
1+
# EPro-PnP cannot be pip-installed (requires mmcv/mmdet C extensions).
2+
# The PoC downloads the vulnerable source file directly from GitHub.
3+
# Pinned commit: 21269649033c464c2c9d829ee9bad09ef6839320
Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
SECRET_KEY = "poc-insecure-key"
2-
DEBUG = True
1+
from pathlib import Path
2+
3+
BASE_DIR = Path(__file__).resolve().parent
4+
5+
SECRET_KEY = "demo-insecure-key-do-not-use-in-production"
6+
DEBUG = False
37
ALLOWED_HOSTS = ["*"]
48
ROOT_URLCONF = "urls"
59
INSTALLED_APPS = [
610
"django.contrib.contenttypes",
711
"django.contrib.auth",
12+
"django.contrib.sessions",
13+
"django.contrib.staticfiles",
814
"django_unicorn",
915
"unicorn",
1016
]
17+
MIDDLEWARE = [
18+
"django.middleware.security.SecurityMiddleware",
19+
"whitenoise.middleware.WhiteNoiseMiddleware",
20+
"django.contrib.sessions.middleware.SessionMiddleware",
21+
"django.middleware.common.CommonMiddleware",
22+
"django.middleware.csrf.CsrfViewMiddleware",
23+
]
1124
TEMPLATES = [
1225
{
1326
"BACKEND": "django.template.backends.django.DjangoTemplates",
@@ -16,8 +29,28 @@
1629
"OPTIONS": {
1730
"context_processors": [
1831
"django.template.context_processors.request",
32+
"django.template.context_processors.static",
1933
],
2034
},
2135
},
2236
]
23-
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
37+
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "db.sqlite3"}}
38+
LOGGING = {
39+
"version": 1,
40+
"handlers": {
41+
"console": {"class": "logging.StreamHandler"},
42+
},
43+
"loggers": {
44+
"django.server": {
45+
"handlers": ["console"],
46+
"level": "INFO",
47+
},
48+
"django.request": {
49+
"handlers": ["console"],
50+
"level": "ERROR",
51+
},
52+
},
53+
}
54+
STATIC_URL = "/static/"
55+
STATIC_ROOT = BASE_DIR / "staticfiles"
56+
STATICFILES_DIRS = ["static"]
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{% load unicorn %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>NovaMart — Modern E-Commerce</title>
8+
<script src="https://cdn.tailwindcss.com"></script>
9+
<script>
10+
tailwind.config = {
11+
theme: {
12+
extend: {
13+
colors: {
14+
brand: { 50: '#f0f9ff', 100: '#e0f2fe', 500: '#0ea5e9', 600: '#0284c7', 700: '#0369a1' },
15+
}
16+
}
17+
}
18+
}
19+
</script>
20+
<style>
21+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
22+
body { font-family: 'Inter', sans-serif; }
23+
.product-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(0,0,0,0.1); }
24+
.product-card { transition: all 0.3s ease; }
25+
.fade-in { animation: fadeIn 0.3s ease-in; }
26+
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
27+
.star-filled { color: #f59e0b; }
28+
.star-empty { color: #d1d5db; }
29+
</style>
30+
{% unicorn_scripts %}
31+
</head>
32+
<body class="bg-gray-50 min-h-screen">
33+
{% csrf_token %}
34+
<!-- Navigation -->
35+
<nav class="bg-white border-b border-gray-200 sticky top-0 z-50 shadow-sm">
36+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
37+
<div class="flex justify-between items-center h-16">
38+
<div class="flex items-center space-x-8">
39+
<a href="/" class="text-2xl font-bold text-brand-700">
40+
<span class="text-brand-500">Nova</span>Mart
41+
</a>
42+
<div class="hidden md:flex space-x-6">
43+
<a href="#" class="text-gray-600 hover:text-brand-600 font-medium text-sm">New Arrivals</a>
44+
<a href="#" class="text-gray-600 hover:text-brand-600 font-medium text-sm">Best Sellers</a>
45+
<a href="#" class="text-gray-600 hover:text-brand-600 font-medium text-sm">Categories</a>
46+
<a href="#" class="text-gray-600 hover:text-brand-600 font-medium text-sm">Deals</a>
47+
</div>
48+
</div>
49+
<div class="flex items-center space-x-4">
50+
<button class="text-gray-500 hover:text-gray-700">
51+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
52+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
53+
</svg>
54+
</button>
55+
<button class="text-gray-500 hover:text-gray-700">
56+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
57+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>
58+
</svg>
59+
</button>
60+
</div>
61+
</div>
62+
</div>
63+
</nav>
64+
65+
<!-- Hero Banner -->
66+
<div class="bg-gradient-to-r from-brand-700 via-brand-600 to-indigo-600 text-white">
67+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
68+
<div class="flex flex-col md:flex-row items-center justify-between">
69+
<div>
70+
<p class="text-brand-100 text-sm font-medium mb-2">SUMMER COLLECTION 2025</p>
71+
<h1 class="text-4xl md:text-5xl font-bold mb-4">Discover What's New</h1>
72+
<p class="text-brand-100 text-lg max-w-lg">Curated products from top brands. Free shipping on orders over $99.</p>
73+
</div>
74+
<div class="mt-6 md:mt-0">
75+
<span class="bg-white/20 backdrop-blur-sm border border-white/30 rounded-full px-6 py-3 text-sm font-medium">
76+
Use code <strong>SUMMER25</strong> for 25% off
77+
</span>
78+
</div>
79+
</div>
80+
</div>
81+
</div>
82+
83+
<!-- Main Content -->
84+
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10">
85+
<!-- Product Search, Filter & Cart -->
86+
{% unicorn 'product_search' %}
87+
88+
<!-- Reviews Section -->
89+
<div class="mt-16 border-t border-gray-200 pt-12">
90+
<h2 class="text-2xl font-bold text-gray-900 mb-8">Customer Reviews</h2>
91+
{% unicorn 'review_form' %}
92+
</div>
93+
</main>
94+
95+
<!-- Footer -->
96+
<footer class="bg-gray-900 text-gray-400 mt-20">
97+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
98+
<div class="grid grid-cols-2 md:grid-cols-4 gap-8">
99+
<div>
100+
<h3 class="text-white font-semibold mb-4">Shop</h3>
101+
<ul class="space-y-2 text-sm">
102+
<li><a href="#" class="hover:text-white">New Arrivals</a></li>
103+
<li><a href="#" class="hover:text-white">Best Sellers</a></li>
104+
<li><a href="#" class="hover:text-white">Sale</a></li>
105+
<li><a href="#" class="hover:text-white">Gift Cards</a></li>
106+
</ul>
107+
</div>
108+
<div>
109+
<h3 class="text-white font-semibold mb-4">Help</h3>
110+
<ul class="space-y-2 text-sm">
111+
<li><a href="#" class="hover:text-white">Shipping</a></li>
112+
<li><a href="#" class="hover:text-white">Returns</a></li>
113+
<li><a href="#" class="hover:text-white">Size Guide</a></li>
114+
<li><a href="#" class="hover:text-white">Contact Us</a></li>
115+
</ul>
116+
</div>
117+
<div>
118+
<h3 class="text-white font-semibold mb-4">About</h3>
119+
<ul class="space-y-2 text-sm">
120+
<li><a href="#" class="hover:text-white">Our Story</a></li>
121+
<li><a href="#" class="hover:text-white">Careers</a></li>
122+
<li><a href="#" class="hover:text-white">Sustainability</a></li>
123+
<li><a href="#" class="hover:text-white">Press</a></li>
124+
</ul>
125+
</div>
126+
<div>
127+
<h3 class="text-white font-semibold mb-4">Connect</h3>
128+
<ul class="space-y-2 text-sm">
129+
<li><a href="#" class="hover:text-white">Instagram</a></li>
130+
<li><a href="#" class="hover:text-white">Twitter</a></li>
131+
<li><a href="#" class="hover:text-white">Facebook</a></li>
132+
<li><a href="#" class="hover:text-white">Newsletter</a></li>
133+
</ul>
134+
</div>
135+
</div>
136+
<div class="border-t border-gray-800 mt-10 pt-8 text-sm text-center">
137+
<p>&copy; 2025 NovaMart. All rights reserved. Built with Django + django-unicorn.</p>
138+
</div>
139+
</div>
140+
</footer>
141+
</body>
142+
</html>

0 commit comments

Comments
 (0)