Class: Rubion::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/rubion/scanner.rb

Defined Under Namespace

Classes: ScanResult

Instance Method Summary collapse

Constructor Details

#initialize(project_path: Dir.pwd, package_manager: nil, vulnerabilities_only: false) ⇒ Scanner

Returns a new instance of Scanner.



23
24
25
26
27
28
29
30
31
# File 'lib/rubion/scanner.rb', line 23

def initialize(project_path: Dir.pwd, package_manager: nil, vulnerabilities_only: false)
  @project_path = project_path
  @result = ScanResult.new
  @package_manager = package_manager
  @package_manager_detected = false
  @direct_gems = nil
  @direct_packages = nil
  @vulnerabilities_only = vulnerabilities_only
end

Instance Method Details

#scanObject



33
34
35
36
37
38
39
40
# File 'lib/rubion/scanner.rb', line 33

def scan
  puts "🔍 Scanning project at: #{@project_path}\n\n"

  scan_ruby_gems
  scan_npm_packages

  @result
end

#scan_incremental(options = { gems: true, packages: true, sort_by: 'Behind By(Time)', sort_desc: true, exclude_dependencies: false }) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rubion/scanner.rb', line 42

def scan_incremental(options = { gems: true, packages: true, sort_by: 'Behind By(Time)', sort_desc: true,
                                 exclude_dependencies: false })
  puts "🔍 Scanning project at: #{@project_path}\n\n"

  # Scan and display Ruby gems first (if enabled)
  if options[:gems]
    scan_ruby_gems

    # Print gem results immediately
    puts "\n"
    reporter = Reporter.new(@result, sort_by: options[:sort_by], sort_desc: options[:sort_desc],
                                     exclude_dependencies: options[:exclude_dependencies])
    reporter.print_gem_vulnerabilities
    reporter.print_gem_versions unless options[:vulnerabilities_only]
  end

  # Then scan NPM packages (if enabled)
  if options[:packages]
    puts "\n" if options[:gems] # Add spacing if gems were scanned
    scan_npm_packages
  end

  @result
end