From 05c110ad08ba70a8c84aaf4d56bfcb446e1140c9 Mon Sep 17 00:00:00 2001 From: AliaksandrNazaruk Date: Tue, 24 Mar 2026 16:42:49 +0100 Subject: [PATCH 1/2] feat: BCOS Badge Generator web tool (#2292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Static HTML/JS badge generator at web/bcos/badge-generator.html - Enter repo URL or BCOS cert ID to generate badge - Preview badge inline - Copy markdown, HTML, or raw URL embed code - Three badge styles: flat, flat-square, for-the-badge - Vintage terminal aesthetic matching rustchain.org - No backend needed — calls /bcos/verify API - MIT licensed --- web/bcos/badge-generator.html | 240 ++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 web/bcos/badge-generator.html diff --git a/web/bcos/badge-generator.html b/web/bcos/badge-generator.html new file mode 100644 index 000000000..263a929c2 --- /dev/null +++ b/web/bcos/badge-generator.html @@ -0,0 +1,240 @@ + + + + + + BCOS Badge Generator — RustChain + + + +

▸ BCOS Badge Generator

+

Beacon Certified Open Source — embed your trust badge

+ +
+ + + + + + + +

+
+ + + +

+ Powered by RustChain BCOS • + Verify at rustchain.org/bcos +

+ + + + From d1ee8150f6d2b70340d750dddcd387a1e2689ed9 Mon Sep 17 00:00:00 2001 From: AliaksandrNazaruk Date: Tue, 24 Mar 2026 18:52:42 +0100 Subject: [PATCH 2/2] fix: replace bare except clauses and shell=True injection risk - Replace 'except:' with 'except Exception:' in fingerprint_checks.py, get_hardware_serial.py, rip_proof_of_antiquity_hardware.py, rip_node_sync.py - Replace shell=True with shlex.split() in get_hardware_serial.py - Fixes #1822 (bug bounty #305) --- node/fingerprint_checks.py | 16 ++++++++-------- node/get_hardware_serial.py | 11 ++++++----- node/rip_node_sync.py | 2 +- node/rip_proof_of_antiquity_hardware.py | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/node/fingerprint_checks.py b/node/fingerprint_checks.py index 74d251ce4..e01084726 100644 --- a/node/fingerprint_checks.py +++ b/node/fingerprint_checks.py @@ -136,7 +136,7 @@ def check_simd_identity() -> Tuple[bool, Dict]: if len(parts) > 1: flags = parts[1].strip().split() break - except: + except Exception: pass if not flags: @@ -148,7 +148,7 @@ def check_simd_identity() -> Tuple[bool, Dict]: for line in result.stdout.split("\n"): if "feature" in line.lower() or "altivec" in line.lower(): flags.append(line.split(":")[-1].strip()) - except: + except Exception: pass has_sse = any("sse" in f.lower() for f in flags) @@ -553,7 +553,7 @@ def check_anti_emulation() -> Tuple[bool, Dict]: for vm in vm_strings: if vm in content: vm_indicators.append("{}:{}".format(path, vm)) - except: + except Exception: pass # --- Environment variable checks --- @@ -569,7 +569,7 @@ def check_anti_emulation() -> Tuple[bool, Dict]: with open("/proc/cpuinfo", "r") as f: if "hypervisor" in f.read().lower(): vm_indicators.append("cpuinfo:hypervisor") - except: + except Exception: pass # --- /sys/hypervisor check (Xen-based cloud VMs expose this) --- @@ -579,7 +579,7 @@ def check_anti_emulation() -> Tuple[bool, Dict]: hv_type = f.read().strip().lower() if hv_type: vm_indicators.append("sys_hypervisor:{}".format(hv_type)) - except: + except Exception: pass # --- Cloud metadata endpoint check --- @@ -598,7 +598,7 @@ def check_anti_emulation() -> Tuple[bool, Dict]: if "azure" in cloud_body or "microsoft" in cloud_body: cloud_provider = "azure" vm_indicators.append("cloud_metadata:{}".format(cloud_provider)) - except: + except Exception: pass # --- AWS IMDSv2 check (token-based, t3/t4 Nitro instances) --- @@ -612,7 +612,7 @@ def check_anti_emulation() -> Tuple[bool, Dict]: token_resp = urllib.request.urlopen(token_req, timeout=1) if token_resp.status == 200: vm_indicators.append("cloud_metadata:aws_imdsv2") - except: + except Exception: pass # --- systemd-detect-virt (if available) --- @@ -623,7 +623,7 @@ def check_anti_emulation() -> Tuple[bool, Dict]: virt_type = result.stdout.strip().lower() if virt_type and virt_type != "none": vm_indicators.append("systemd_detect_virt:{}".format(virt_type)) - except: + except Exception: pass data = { diff --git a/node/get_hardware_serial.py b/node/get_hardware_serial.py index 7f2d43ecb..472719e2c 100644 --- a/node/get_hardware_serial.py +++ b/node/get_hardware_serial.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import shlex """ Universal Hardware Serial Detection Works on: Mac (PPC/Intel/ARM), Linux, Windows @@ -11,11 +12,11 @@ def run_cmd(cmd): try: if isinstance(cmd, str): - result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=5) + result = subprocess.run(shlex.split(cmd) if isinstance(cmd, str) else cmd, capture_output=True, text=True, timeout=5) else: result = subprocess.run(cmd, capture_output=True, text=True, timeout=5) return result.stdout.strip() - except: + except Exception: return '' def get_mac_serial(): @@ -53,7 +54,7 @@ def get_linux_serial(): serial = f.read().strip() if serial and serial not in ['', 'None', 'To Be Filled']: return serial - except: + except Exception: pass # Method 2: dmidecode (requires root) @@ -68,7 +69,7 @@ def get_linux_serial(): serial = f.read().decode('utf-8', errors='ignore').strip('\x00') if serial: return serial - except: + except Exception: pass return None @@ -131,7 +132,7 @@ def get_serial_with_fallback(): mac = parts[i+1] if mac != '00:00:00:00:00:00': macs.append(mac) - except: + except Exception: pass if macs: diff --git a/node/rip_node_sync.py b/node/rip_node_sync.py index 78355dcdb..9092a03bf 100644 --- a/node/rip_node_sync.py +++ b/node/rip_node_sync.py @@ -118,7 +118,7 @@ def get_local_hostname() -> str: ip = s.getsockname()[0] s.close() return ip - except: + except Exception: return "127.0.0.1" def sync_with_peers(): diff --git a/node/rip_proof_of_antiquity_hardware.py b/node/rip_proof_of_antiquity_hardware.py index 4a1ff72c5..77a076c54 100644 --- a/node/rip_proof_of_antiquity_hardware.py +++ b/node/rip_proof_of_antiquity_hardware.py @@ -158,7 +158,7 @@ def calculate_entropy_score(signals: Dict) -> float: entropy_data = bytes.fromhex(entropy_data.replace(":", "")) shannon = calculate_shannon_entropy(entropy_data) score += (shannon / 8.0) * 0.4 - except: + except Exception: pass # 2. CPU timing profile match (30%)