Skip to content

Commit 42d7cd1

Browse files
committed
feat: restructure Vimana to use ~/.vimana directory layout
- Move framework to ~/.vimana/repo (VIMANA_PATH) - Migrate plugin cache from ~/vimana to ~/.vimana/cache - Update install scripts for new directory structure - Add backward compatibility for existing installations - Enable lab discovery at ~/.vimana/repo/siddhis/*/lab/^X
1 parent 1a6f57b commit 42d7cd1

File tree

16 files changed

+608
-22
lines changed

16 files changed

+608
-22
lines changed

core/labs/vmnf_labs.py

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.

core/navi/collections/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import io
4141
import os
4242

43-
vimana_path = os.getenv("vimana_path")
43+
vimana_path = os.getenv("VIMANA_PATH") or os.getenv("vimana_path")
4444

4545
class xc_handler:
4646
def __init__(self, vmnf_handler:dict) -> None:

core/vmnf_arg_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ def parse_args(self):
178178
run_cmd.add_argument('--workflow', action='store', nargs='?', default=False, dest='workflow')
179179
run_cmd.add_argument('--channel', action='store', nargs='?', default=False, dest='cmd_channel')
180180
run_cmd.add_argument('--ci-mode', action='store_true', dest='ci_mode')
181+
run_cmd.add_argument('--lab', action='store', dest='run_lab', help='Run a lab for the specified plugin')
182+
run_cmd.add_argument('--lab-operation', action='store', dest='lab_operation',
183+
choices=['start', 'stop', 'status', 'list', 'cleanup'],
184+
default='start', help='Lab operation to perform (default: start)')
181185
#run_cmd.add_argument('--cmd', action='store', nargs='?', default=False, dest='cmd')
182186
#run_cmd.add_argument('--pycode', action='store', nargs='?', default=False, dest='pycode')
183187

@@ -333,6 +337,8 @@ def start_handler(self):
333337
module_run = False,
334338
siddhi_run = False,
335339
plugin_run = False,
340+
run_lab = False,
341+
lab_operation = False,
336342
external_disabled = False,
337343
module_list = False,
338344
list_payloads = False,

core/vmnf_engine.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ def abduct():
187187

188188
handler_ns.start_resource.append(arg)
189189

190+
if handler_ns.run_lab:
191+
from core.labs.vmnf_labs import handle_lab_command
192+
handle_lab_command(handler_ns)
193+
return True
194+
190195
# ~ new in vimana 1.0 - run plugin by name directly
191196
if hasattr(handler_ns, 'plugin_name') and handler_ns.plugin_name:
192197

@@ -301,7 +306,12 @@ def abduct():
301306

302307
#~ list all channels
303308
elif handler_ns.list_channels:
304-
from core.vmnf_channels import list_channels, get_channels_by_type, get_channels_by_plugin, get_channels_by_target
309+
from core.vmnf_channels import (
310+
list_channels,
311+
get_channels_by_type,
312+
get_channels_by_plugin,
313+
get_channels_by_target
314+
)
305315
from neotermcolor import colored
306316

307317
# Check if summary mode is requested

core/vmnf_navi_sessions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from urllib.parse import urlparse, urljoin
3333
from datetime import datetime
3434

35-
vimana_path = os.getenv("vimana_path")
35+
vimana_path = os.getenv("VIMANA_PATH") or os.getenv("vimana_path")
3636

3737

3838
class naviSessions:

core/vmnf_scan_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import io
4141
import os
4242

43-
vimana_path = os.getenv("vimana_path")
43+
vimana_path = os.getenv("VIMANA_PATH") or os.getenv("vimana_path")
4444

4545
class naviScan:
4646
def __init__(self, vmnf_handler:dict) -> None:

scripts/install

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,47 @@
66
# One-liner installer for Vimana Framework
77
# Usage: curl -s https://raw.githubusercontent.com/s4dhulabs/vimana-framework/develop/scripts/install | bash
88

9-
echo "🚀 Installing Vimana Framework to ~/vimana-framework..."
9+
echo "🚀 Installing Vimana Framework to ~/.vimana/repo..."
1010

11-
# Change to home directory
12-
cd ~
11+
# Create .vimana directory structure
12+
VIMANA_HOME="$HOME/.vimana"
13+
VIMANA_REPO="$VIMANA_HOME/repo"
14+
15+
echo "📁 Creating Vimana directory structure..."
16+
mkdir -p "$VIMANA_HOME"/{cache,logs,outputs}
1317

1418
# Remove existing installation if it exists
15-
if [ -d "vimana-framework" ]; then
19+
if [ -d "$VIMANA_REPO" ]; then
1620
echo "🗑️ Removing existing installation..."
17-
rm -rf vimana-framework
21+
rm -rf "$VIMANA_REPO"
1822
fi
1923

20-
# Clone the repository to home directory
21-
if ! git clone -b develop https://github.com/s4dhulabs/vimana-framework.git; then
24+
# Clone the repository directly to ~/.vimana/repo
25+
if ! git clone -b develop https://github.com/s4dhulabs/vimana-framework.git "$VIMANA_REPO"; then
2226
echo "❌ Failed to clone repository"
2327
exit 1
2428
fi
2529

2630
# Change to directory and run setup
27-
cd vimana-framework
31+
cd "$VIMANA_REPO"
2832

2933
# Make the script executable and source it
3034
chmod +x scripts/setup-uv
3135
source scripts/setup-uv
3236

3337
# Create symlink for vfe (Vimana Framework Environment)
3438
echo "🔗 Creating vfe symlink for easy access..."
35-
sudo ln -sf "$PWD/scripts/vfe" /usr/bin/vfe
39+
sudo ln -sf "$VIMANA_REPO/scripts/vfe" /usr/bin/vfe
40+
41+
# Set environment variables
42+
echo "🔧 Setting environment variables..."
43+
export VIMANA_HOME="$HOME/.vimana"
44+
export VIMANA_PATH="$VIMANA_HOME/repo"
3645

3746
echo ""
3847
echo "🎉 Vimana Framework installation complete!"
39-
echo "📁 Installed to: ~/vimana-framework"
48+
echo "📁 Installed to: ~/.vimana/repo"
49+
echo "📁 Data directory: ~/.vimana"
4050
echo ""
4151
echo "🚀 Quick start:"
4252
echo " source vfe # Activate environment from anywhere"

scripts/setup-uv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ fi
2424
echo "🔧 Creating virtual environment..."
2525
uv sync
2626

27+
# Set environment variables
28+
echo "🔧 Setting environment variables..."
29+
export VIMANA_HOME="${VIMANA_HOME:-$HOME/.vimana}"
30+
export VIMANA_PATH="${VIMANA_PATH:-$PWD}"
31+
32+
# Create .vimana directory structure if it doesn't exist
33+
mkdir -p "$VIMANA_HOME"/{cache,logs,outputs}
34+
2735
# Create symlinks
2836
echo "🔗 Creating symlinks..."
2937
sudo ln -sf $PWD/vimana.py /usr/bin/vimana
@@ -54,6 +62,8 @@ echo ""
5462
echo "🎊 Vimana Framework Setup completed successfully!"
5563
echo "💡 Run 'vimana' or 'vf' to start the framework"
5664
echo "🌐 Virtual environment: $PWD/.venv (in project directory)"
65+
echo "🏠 VIMANA_HOME: $VIMANA_HOME"
66+
echo "📁 VIMANA_PATH: $VIMANA_PATH"
5767
echo "💡 Use 'uv run vf' to run with proper environment"
5868
echo ""
5969

siddhis/d4m8/engines/_d4m8_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(self, *args,**handler):
103103

104104
issue_type = 'dast/output'
105105
plugin_scope = f'django/{issue_type}'
106-
self.cache_dir = f"vimana/__cache__/{plugin_scope}"
106+
self.cache_dir = f".vimana/cache/{plugin_scope}"
107107
self.abs_cache_path = os.path.join(os.path.expanduser("~"), self.cache_dir)
108108

109109
self.agressive_mode = self.handler.get('agressive_mode')

siddhis/d4m8/navi/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import io
5050
import os
5151

52-
vimana_path = os.getenv("vimana_path")
52+
vimana_path = os.getenv("VIMANA_PATH") or os.getenv("vimana_path")
5353

5454
class navi_handler:
5555
def __init__(self, vmnf_handler:dict) -> None:

0 commit comments

Comments
 (0)