How niranjan017/web-secure works
Project Type and Purpose
• This is a full-stack web application named “web-secure” that provides security scanning of web resources.
• The frontend is a static HTML/JS UI for users to log in, configure scans, view dashboards/reports.
• The backend is a Node.js/Express API that manages authentication, scan requests, report persistence, and orchestrates Python‐based scanning modules.
• A database stores user records, scan requests, and scan results.
File Structure
• Top level:
• backend/ (Express server, routes, middleware, small Python scanner scripts, db.js)
• frontend/ (static HTML pages, CSS, JS under script/)
• package.json (likely for the entire project or root tooling)
• backend/
• server.js: Express app bootstrap
• routes/: REST endpoints (auth, authcheck, user, scan, repot, savescan)
• middleware/authenticateToken.js: JWT or token‐based auth guard
• scanner/: Python scripts (cs.py, ps.py, si.py, x.py, security_headers.py) – each module handles a specific security test
• db.js: database connection logic (likely MongoDB or similar)
• .env: secrets (DB URI, JWT secret, API keys)
• frontend/
• HTML pages reflect each UI view (login, scan, dash, report, blog, etc.)
• script/: JS controllers for each page that call backend APIs
README
• The README only contains the project title. We infer from code that the stack is Node.js + Express + a NoSQL/SQL database + Python scanners + static frontend.
a. Main Components
• User’s Browser (UI) – hosts the frontend HTML/CSS/JS
• Frontend Static Server – can be CDN or web server serving HTML & JS
• API Gateway (Node.js/Express) – handles HTTP(S) requests
• Authentication Module – JWT issuance & verification (middleware)
• Scanner Orchestrator – Express invokes Python scripts via child process or REST calls
• Python Scanner Modules – cs.py, ps.py, security_headers.py, etc.
• Database – stores Users, Scans, Reports
• (Optional) File Storage – if large reports or logs are stored on disk or S3
• External Services – email service, webhook targets, etc., if used
b. Relationships & Interactions
1. User logs in via frontend → POST /auth → Express → db → JWT token
2. Frontend sends scan request → Express /scan route → validates token → writes Scan record to DB → triggers Python scanner modules
3. Scanner modules execute tests and return JSON results → Express collects results → saves to DB (ScanResults) → triggers notify or returns response
4. Frontend polls or fetches /report → Express reads from DB → returns report data → UI renders charts
c. Architectural Patterns & Principles
• Separation of Concerns: frontend UI vs. backend API vs. scanning logic
• Micro-modules for scanning: each Python script is a self-contained test
• Token-based stateless auth (JWT)
• RESTful API design
d. Key Technologies & Frameworks
• Node.js, Express.js, dotenv
• Python for security scanning scripts
• MongoDB or other DB (via db.js)
• JWT for authentication
• Static HTML/CSS/Vanilla JS on frontend