Skip to content

nKOxxx/2ndCTO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

2ndCTO - AI-Powered Codebase Risk Analyzer

Version GitHub Node.js License

Know Your Codebase Risk. Protect Your Engineering Investment.

2ndCTO analyzes GitHub repositories for security risks, bus factor (knowledge concentration), and technical debt. Get actionable insights to keep your codebase healthy and your team resilient.

2ndCTO Dashboard

πŸš€ Features

Security Analysis

  • πŸ”’ Secret Detection - Find API keys, passwords, tokens in code
  • πŸ›‘οΈ Vulnerability Scanning - SQL injection, XSS, unsafe eval detection
  • πŸ“Š Risk Scoring - 0-100 score with severity breakdown

Bus Factor Analysis

  • 🚌 Knowledge Distribution - Identify single points of failure
  • πŸ‘₯ Team Insights - See who knows what in your codebase
  • ⚠️ Risk Alerts - Get warned before knowledge walks out the door

Code Modernization

  • πŸ”„ Legacy Conversion - ES5 β†’ ES2022, Python 2 β†’ 3
  • πŸ“ˆ Pattern Detection - Callbacks β†’ async/await, var β†’ const
  • βœ… Validation - Syntax check and test generation

AI-Powered Insights

  • πŸ€– Smart Recommendations - Prioritized action plans
  • πŸ’‘ Fix Suggestions - Before/after code examples
  • πŸ“ˆ Trend Analysis - Track improvements over time

πŸ“¦ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • PostgreSQL (Supabase recommended)
  • Redis (Upstash recommended)

Installation

# Clone the repository
git clone https://github.com/nKOxxx/2ndCTO.git
cd 2ndCTO

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env with your credentials

# Run database migrations
# (See scripts/ folder for SQL files)

# Start the application
npm run dev

Environment Variables

# Server
PORT=3001
NODE_ENV=development

# Supabase
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_KEY=your_service_key

# Redis
REDIS_URL=rediss://your_upstash_url

# GitHub
GITHUB_TOKEN=your_github_personal_access_token

🎯 Usage

Web Interface

  1. Landing Page - http://localhost:3001
  2. Dashboard - http://localhost:3001/dashboard.html
  3. Analyze Repo - Enter GitHub URL and click "Analyze"

API Endpoints

# Add repository
curl -X POST http://localhost:3001/api/repos \
  -H "Content-Type: application/json" \
  -d '{"owner":"facebook","name":"react"}'

# Get analysis report
curl http://localhost:3001/api/repos/{repo-id}/report

# Get AI insights
curl http://localhost:3001/api/repos/{repo-id}/insights

# Get bus factor
curl http://localhost:3001/api/repos/{repo-id}/bus-factor

Chrome Extension

  1. Open Chrome β†’ chrome://extensions/
  2. Enable "Developer mode"
  3. Click "Load unpacked"
  4. Select the chrome-extension/ folder
  5. Visit any GitHub repo and click "Analyze with 2ndCTO"

GitHub Action

name: Security Analysis
on: [push, pull_request]

jobs:
  analyze:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    
    steps:
      - uses: actions/checkout@v4
      
      - uses: nKOxxx/2ndCTO/.github/actions/2ndcto-analyze@main
        with:
          server-url: 'http://your-2ndcto-server.com'
          fail-on-critical: 'true'
          create-issues: 'true'

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Chrome Ext    β”‚     β”‚   Web Dashboard β”‚     β”‚   GitHub Action β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     Express API (3001)    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                        β”‚                        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PostgreSQL     β”‚    β”‚  Redis (Bull)      β”‚   β”‚   GitHub API    β”‚
β”‚  (Supabase)     β”‚    β”‚  (Job Queue)       β”‚   β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

  • Backend: Node.js, Express.js
  • Database: PostgreSQL (Supabase)
  • Queue: Redis + Bull
  • Parser: Tree-sitter (AST analysis)
  • Frontend: Vanilla HTML/JS (no framework)
  • Real-time: Socket.io

πŸ“Š Understanding Reports

Risk Score (0-100)

Score Grade Meaning Action
0-30 A Excellent Maintain practices
30-50 B Good Minor improvements
50-70 C Fair Review recommended
70-90 D Poor Address issues soon
90-100 F Critical Immediate action

Bus Factor

Score Status Interpretation
1-1.5 πŸ”΄ Critical Single point of failure
1.5-2.5 🟑 Warning Limited knowledge spread
2.5-4 🟒 Good Decent distribution
4+ 🟒 Excellent Healthy team resilience

πŸ› οΈ Development

Project Structure

2ndCTO/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/           # Express routes
β”‚   β”œβ”€β”€ analysis/      # Code analyzers
β”‚   β”œβ”€β”€ db/            # Database connection
β”‚   β”œβ”€β”€ ingestion/     # Repo cloning
β”‚   β”œβ”€β”€ queue/         # Bull job queue
β”‚   └── index.js       # Entry point
β”œβ”€β”€ public/            # Static files (UI)
β”œβ”€β”€ chrome-extension/  # Browser extension
β”œβ”€β”€ scripts/           # SQL migrations
└── .github/           # GitHub Actions

Running Tests

npm test

Adding New Security Rules

Edit src/analysis/security-scanner.js:

{
  id: 'MY_NEW_RULE',
  name: 'Descriptive Name',
  pattern: /regex pattern/,
  severity: 'high',
  category: 'vulnerability'
}

πŸš€ Deployment

Render (Recommended)

  1. Push to GitHub
  2. Connect Render to repo
  3. Set environment variables
  4. Deploy!

Docker

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3001
CMD ["npm", "start"]
docker build -t 2ndcto .
docker run -p 3001:3001 --env-file .env 2ndcto

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

  • Tree-sitter for AST parsing
  • Supabase for managed PostgreSQL
  • Upstash for Redis hosting
  • GitHub for the API

πŸ“ž Support


Built with ❀️ by 2ndCTO Team

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors