🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

sitedog_parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitedog_parser

0.4.1
Rubygems
Version published
Maintainers
1
Created
Source

SitedogParser

A library for parsing and classifying web services from YAML files into structured Ruby objects.

Installation

gem 'sitedog_parser'

Usage

Basic Usage

require 'sitedog_parser'

# Parse from a YAML file
parsed_data = SitedogParser::Parser.parse_file('data.yml')

# Working with specific domain's services
domain_services = parsed_data['example.com']
if domain_services[:hosting]
  puts "Hosting: #{domain_services[:hosting].first.service}"
  puts "URL: #{domain_services[:hosting].first.url}"
end

Simple Fields

You can specify which fields should be treated as simple values:

# Define simple fields
simple_fields = [:project, :role, :environment, :registry]

# Parse with simple fields
parsed_data = SitedogParser::Parser.parse(yaml_data, simple_fields: simple_fields)

# Find domains with a specific field value
production_domains = SitedogParser::Parser.get_domains_by_field_value(parsed_data, :environment, 'production')

Export to JSON

# Standard output
json_data = SitedogParser::Parser.to_json('services.yml')

# Or via command line:
# $ sitedog_cli services.yml > services.json

# Compact JSON for inner objects
# $ sitedog_cli -C services.yml > services.json

JSON Structure Example

{
  "example.com": {
    "hosting": [{"service":"Amazon Web Services","url":"https://aws.amazon.com"}],
    "dns": [{"service":"Cloudflare","url":"https://cloudflare.com"}],
    "registrar": [{"service":"Namecheap","url":"https://namecheap.com"}]
  }
}

Service Object

service.service  # Name of the service (capitalized string)
service.url      # URL of the service (string or nil)
service.children # Child services (array of Service objects, empty if none)

Supported Data Formats

The library handles various data formats:

  • URL strings: "https://github.com/username/repo" → GitHub service
  • Service names: "GitHub" → GitHub service with URL
  • Hashes with service and URL: {service: "Github", url: "https://github.com/repo"}
  • Nested hashes with service types
  • Hashes with URLs as values

Dictionary Analysis

# Find candidates for the dictionary (services with name but no URL)
candidates = SitedogParser::DictionaryAnalyzer.find_dictionary_candidates(parsed_data)

# Generate a report
report = SitedogParser::DictionaryAnalyzer.report(parsed_data)

Command Line Options

$ sitedog_cli --help
Usage: sitedog_cli [options] <path_to_yaml_file> [output_file]
    -d, --debug                 Enable debug output
    -c, --compact               Compact JSON without formatting
    -C, --compact-children      Formatted JSON with compact inner objects
    -q, --quiet                 Suppress non-error messages
    -h, --help                  Show this help message

License

MIT

FAQs

Package last updated on 20 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts