Class: QueryGuard::Uploader::HttpUploader

Inherits:
Interface
  • Object
show all
Defined in:
lib/query_guard/uploader/http_uploader.rb

Overview

HTTP uploader for sending reports to a remote QueryGuard API.

This is a template/stub uploader for future SaaS platform integration. It provides the interface for authenticated HTTPS uploads but is not yet connected to a production service.

Configuration:

config.uploader_type = 'http'
config.api_base_url = 'https://api.queryguard.example.com'
config.project_key = 'proj-123'
config.api_token = 'token-secret'

Use case (future):

  • Upload findings to hosted QueryGuard platform
  • Centralized reporting & analytics
  • Team collaboration on findings
  • Integration with compliance dashboards

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ HttpUploader

Create HTTP uploader from config.

Parameters:



26
27
28
29
30
31
# File 'lib/query_guard/uploader/http_uploader.rb', line 26

def initialize(config)
  @config = config
  @api_base_url = config.api_base_url
  @project_key = config.project_key
  @api_token = config.api_token
end

Instance Method Details

#name ⇒ Object



66
67
68
# File 'lib/query_guard/uploader/http_uploader.rb', line 66

def name
  'http'
end

#ready? ⇒ Boolean

Check if configuration is complete.

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/query_guard/uploader/http_uploader.rb', line 60

def ready?
  !!(@api_base_url && !@api_base_url.empty? &&
    @project_key && !@project_key.empty? &&
    @api_token && !@api_token.empty?)
end

#status ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'lib/query_guard/uploader/http_uploader.rb', line 70

def status
  {
    enabled: ready?,
    mode: 'http',
    api_url: @api_base_url,
    project_key: @project_key,
    description: ready? ? 'Configured for remote API upload' : 'Not configured (missing credentials)'
  }
end

#upload(json_report, metadata = {}) ⇒ UploadResult

Upload JSON report to remote API.

Parameters:

  • json_report (String) —

    JSON report string

  • metadata (Hash) (defaults to: {}) —

    Additional metadata (tracing, timing, etc.)

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/query_guard/uploader/http_uploader.rb', line 38

def upload(json_report,  = {})
  unless ready?
    return UploadResult.new(
      success: false,
      uploader_name: name,
      error: "HTTP uploader not properly configured (missing #{missing_fields.join(', ')})"
    )
  end

  # Parse report to extract metadata

  report_data = parse_report(json_report)

  perform_upload(json_report, report_data, )
rescue StandardError => e
  UploadResult.new(
    success: false,
    uploader_name: name,
    error: "Upload failed: #{e.message}"
  )
end