chore: fix license, add disclaimer, quick start, GitHub topics, issue templates

This commit is contained in:
mukul975
2026-03-11 01:42:17 +01:00
parent e09b84a7da
commit 4ed6f49151
1468 changed files with 152538 additions and 13660 deletions
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -0,0 +1,46 @@
---
name: implementing-runtime-application-self-protection
description: Deploy Runtime Application Self-Protection (RASP) agents to detect and block attacks from within application runtime, covering OpenRASP integration, attack pattern detection, and security policy configuration for Java and Python web applications.
domain: cybersecurity
subdomain: application-security
tags: [rasp, application-security, openrasp, runtime-protection, sqli, xss, rce, devsecops]
version: "1.0"
author: mahipal
license: Apache-2.0
---
# Implementing Runtime Application Self-Protection
## Overview
Runtime Application Self-Protection (RASP) instruments application code at runtime to detect and block attacks by examining actual execution context rather than relying solely on network traffic patterns. Unlike WAFs that inspect HTTP requests externally, RASP agents intercept dangerous operations (SQL queries, file operations, command execution, deserialization) at the function level inside the application, achieving near-zero false positives. This skill covers deploying OpenRASP for Java applications, configuring detection policies for OWASP Top 10 attacks, tuning alerting thresholds, and integrating RASP telemetry with SIEM platforms.
## Prerequisites
- Java 8+ application server (Tomcat, Spring Boot, or JBoss) or Python Flask/Django application
- OpenRASP agent package (rasp-java or equivalent)
- OpenRASP management console for centralized policy management
- SIEM integration endpoint (Splunk HEC, Elasticsearch, or syslog)
- Application staging environment for RASP testing before production
## Steps
### Step 1: Deploy RASP Agent
Install the RASP agent into the application server runtime using JVM agent attachment for Java or middleware hooks for Python.
### Step 2: Configure Detection Policies
Define detection rules for SQL injection, command injection, SSRF, path traversal, XXE, and deserialization attacks with block or monitor actions.
### Step 3: Tune and Baseline
Run the agent in monitor mode during normal operations to establish baseline behavior and tune policies to reduce false positives before switching to block mode.
### Step 4: Integrate with SIEM
Forward RASP alerts to the SIEM for correlation with WAF, IDS, and authentication events to build comprehensive attack timelines.
## Expected Output
JSON report containing RASP policy audit results, detected attack attempts with stack traces, blocked requests summary, and coverage assessment against OWASP Top 10.
@@ -0,0 +1,99 @@
# API Reference: Implementing Runtime Application Self-Protection
## OpenRASP Deployment
```bash
# Java agent attachment (Tomcat)
export CATALINA_OPTS="-javaagent:/opt/rasp/rasp.jar"
# Spring Boot
java -javaagent:/opt/rasp/rasp.jar -jar app.jar
# Verify agent loaded
curl -s http://localhost:8080/rasp/status
```
## OpenRASP Configuration (rasp.yaml)
```yaml
# Detection plugin settings
plugin:
timeout: 100 # Plugin execution timeout (ms)
maxstack: 100 # Max stack frames to capture
# Block vs monitor mode
block:
status_code: 302 # HTTP status on block
redirect_url: /blocked.html
# Log settings
log:
maxstack: 50
syslog:
enable: true
url: "udp://siem.example.com:514"
tag: openrasp
```
## Detection Hooks
| Hook Point | Attack Type | OWASP |
|------------|-------------|-------|
| sql_query | SQL Injection | A03:2021 |
| command_exec | OS Command Injection | A03:2021 |
| file_open / file_read | Path Traversal | A01:2021 |
| http_request | SSRF | A10:2021 |
| xml_parse | XXE | A05:2021 |
| deserialize | Insecure Deserialization | A08:2021 |
| response_write | XSS (reflected) | A03:2021 |
| ldap_query | LDAP Injection | A03:2021 |
| code_eval | Remote Code Execution | A03:2021 |
## Attack Log Format (JSON)
```json
{
"attack_type": "sqli",
"action": "block",
"client_ip": "192.168.1.50",
"request_url": "/api/users?id=1 OR 1=1",
"attack_params": {"id": "1 OR 1=1"},
"stack_trace": "com.app.UserDAO.findById(UserDAO.java:42)",
"plugin_name": "sql_injection",
"timestamp": "2025-06-15T10:30:00Z"
}
```
## RASP vs WAF Comparison
| Feature | WAF | RASP |
|---------|-----|------|
| Inspection point | Network perimeter | Inside application |
| Context | HTTP request only | Request + execution context |
| False positive rate | Higher | Near-zero |
| Encrypted traffic | Requires TLS termination | Sees plaintext |
| Deployment | Network device/proxy | Application library |
## Python RASP (Flask Middleware Example)
```python
from flask import request, abort
import re
SQL_INJECTION_PATTERN = re.compile(
r"(\b(union|select|insert|update|delete|drop|alter)\b.*\b(from|into|table|set)\b)",
re.IGNORECASE
)
@app.before_request
def rasp_check():
for value in request.values.values():
if SQL_INJECTION_PATTERN.search(str(value)):
abort(403, description="RASP: SQL injection blocked")
```
### References
- OpenRASP: https://github.com/baidu/openrasp
- OWASP RASP: https://owasp.org/www-community/Runtime_Application_Self-Protection
- NIST AppSec: https://csrc.nist.gov/publications/detail/sp/800-95/final
@@ -0,0 +1,163 @@
#!/usr/bin/env python3
"""RASP Agent - audits runtime application protection config, attack logs, and coverage."""
import json
import argparse
import logging
import os
import re
from collections import defaultdict
from datetime import datetime
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
logger = logging.getLogger(__name__)
OWASP_TOP10_CHECKS = {
"sqli": {"name": "SQL Injection", "owasp": "A03:2021", "hook": "sql_query"},
"cmdi": {"name": "Command Injection", "owasp": "A03:2021", "hook": "command_exec"},
"ssrf": {"name": "Server-Side Request Forgery", "owasp": "A10:2021", "hook": "http_request"},
"path_traversal": {"name": "Path Traversal", "owasp": "A01:2021", "hook": "file_open"},
"xxe": {"name": "XML External Entity", "owasp": "A05:2021", "hook": "xml_parse"},
"deserialization": {"name": "Insecure Deserialization", "owasp": "A08:2021", "hook": "deserialize"},
"xss": {"name": "Cross-Site Scripting", "owasp": "A03:2021", "hook": "response_write"},
"ldap_injection": {"name": "LDAP Injection", "owasp": "A03:2021", "hook": "ldap_query"},
"rce": {"name": "Remote Code Execution", "owasp": "A03:2021", "hook": "code_eval"},
}
def parse_rasp_config(config_file):
"""Parse OpenRASP or RASP agent configuration."""
with open(config_file) as f:
return json.load(f)
def audit_rasp_policy(config):
"""Audit RASP detection policies against OWASP Top 10 coverage."""
findings = []
enabled_checks = config.get("detection_plugins", {})
for check_id, check_info in OWASP_TOP10_CHECKS.items():
plugin = enabled_checks.get(check_id, {})
if not plugin.get("enabled", False):
findings.append({
"check": check_id, "name": check_info["name"],
"owasp": check_info["owasp"], "status": "disabled",
"severity": "high",
"recommendation": f"Enable {check_info['name']} detection plugin",
})
elif plugin.get("action", "log") != "block":
findings.append({
"check": check_id, "name": check_info["name"],
"owasp": check_info["owasp"], "status": "monitor_only",
"severity": "medium",
"recommendation": f"Switch {check_info['name']} from monitor to block mode",
})
block_mode = config.get("global_action", "log")
if block_mode == "log":
findings.append({
"check": "global_mode", "status": "monitor_only",
"severity": "high",
"recommendation": "Switch RASP from monitor to block mode after baseline period",
})
return findings
def analyze_attack_logs(log_file, limit=10000):
"""Analyze RASP attack detection logs."""
attacks = []
by_type = defaultdict(int)
by_source = defaultdict(int)
blocked = 0
try:
with open(log_file) as f:
for i, line in enumerate(f):
if i >= limit:
break
try:
event = json.loads(line)
attack_type = event.get("attack_type", "unknown")
by_type[attack_type] += 1
by_source[event.get("client_ip", "")] += 1
if event.get("action") == "block":
blocked += 1
attacks.append(event)
except json.JSONDecodeError:
continue
except FileNotFoundError:
logger.warning("RASP log file not found: %s", log_file)
return {
"total_attacks": len(attacks),
"blocked": blocked,
"block_rate": round(blocked / max(len(attacks), 1) * 100, 1),
"by_attack_type": dict(sorted(by_type.items(), key=lambda x: x[1], reverse=True)),
"top_sources": dict(sorted(by_source.items(), key=lambda x: x[1], reverse=True)[:10]),
}
def check_agent_health(config):
"""Verify RASP agent deployment health."""
findings = []
if not config.get("agent_version"):
findings.append({"issue": "Agent version unknown", "severity": "medium"})
if config.get("cpu_limit_percent", 100) > 10:
findings.append({
"issue": f"CPU limit set to {config.get('cpu_limit_percent')}% (recommend < 5%)",
"severity": "low",
})
if not config.get("siem_integration", {}).get("enabled"):
findings.append({
"issue": "SIEM log forwarding not configured",
"severity": "high",
"recommendation": "Enable syslog or webhook forwarding to SIEM",
})
return findings
def calculate_coverage(config):
"""Calculate OWASP Top 10 coverage percentage."""
enabled_checks = config.get("detection_plugins", {})
covered = sum(1 for check_id in OWASP_TOP10_CHECKS if enabled_checks.get(check_id, {}).get("enabled"))
return {
"total_checks": len(OWASP_TOP10_CHECKS),
"enabled": covered,
"coverage_percent": round(covered / len(OWASP_TOP10_CHECKS) * 100, 1),
}
def generate_report(policy_findings, attack_analysis, health_findings, coverage, config):
all_findings = policy_findings + health_findings
return {
"timestamp": datetime.utcnow().isoformat(),
"rasp_agent": config.get("agent_type", "openrasp"),
"agent_version": config.get("agent_version", "unknown"),
"global_mode": config.get("global_action", "log"),
"owasp_coverage": coverage,
"policy_findings": policy_findings,
"attack_analysis": attack_analysis,
"health_findings": health_findings,
"total_findings": len(all_findings),
"critical_findings": sum(1 for f in all_findings if f.get("severity") == "critical"),
}
def main():
parser = argparse.ArgumentParser(description="RASP Security Audit Agent")
parser.add_argument("--config", required=True, help="RASP agent config JSON file")
parser.add_argument("--attack-log", help="RASP attack log file (JSON lines)")
parser.add_argument("--output", default="rasp_audit_report.json")
args = parser.parse_args()
config = parse_rasp_config(args.config)
policy_findings = audit_rasp_policy(config)
attack_analysis = analyze_attack_logs(args.attack_log) if args.attack_log else {}
health_findings = check_agent_health(config)
coverage = calculate_coverage(config)
report = generate_report(policy_findings, attack_analysis, health_findings, coverage, config)
with open(args.output, "w") as f:
json.dump(report, f, indent=2, default=str)
logger.info("RASP audit: %.1f%% OWASP coverage, %d findings, mode: %s",
coverage["coverage_percent"], report["total_findings"], config.get("global_action", "log"))
print(json.dumps(report, indent=2, default=str))
if __name__ == "__main__":
main()