Project

opensaz

0.0
No commit activity in last 3 years
No release in over 3 years
a handy tool to read from .saz file(package captured by Fiddler).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 5.0
~> 10.0

Runtime

 Project Readme

Opensaz

This is my first serious repo.!

It's a Ruby Gem.

It's used to read .saz file(generated by Fiddler, consist of HTTP requests and responses).

Installation

$ gem install opensaz

Usage

Read .saz file

A .saz file is simply a compressed file. You can extract it with 7zip. The folder structure and content after extraction are very clear.

The first time when you call Opensaz.read('any.saz'), it will extract all the contents into folder any_#{md5}. The next time you run it, as any_#{md5} already exists(unless you remove it), this function will return the path directly instead of extracting the content again.

# will create folder like https_e5125274177355d294051e92098a2e58
a = Opensaz.read("/Users/keegoo/workspace/https.saz")

Packages

A package is an HTTP interaction(request and response) between client and server.

Typically a package consist of id, comment, request and response.

id: is the number in the first column of packages-list in Fiddler UI.
comment: in Fiddler UI, you can add comment for each package.
request: a HTTP request.
response: a HTTP response.
require 'opensaz'

a = Opensaz.read("/Users/keegoo/workspace/entity.saz")

a.packages.each do |x|
  puts x.id
  puts x.comment
  puts x.request.headers[:path]
  puts x.request.headers[:method]
  puts x.request.headers[:content_type]
  puts x.request.body

  puts x.response.headers
  puts x.response.body
end

As a package is either HTTP or HTTPS protocol, you could pass :http or :https to filter it.

It support :http, :https and :all(default value).

a.packages(:http).each do |x|
  # do anything
end

You could use Ruby build-in methods select to do some filtering.

a.packages.select{|x|x.comment =~ /some import message/}

a.packages.select{|x|x.request.headers[:content_type] == "text/xml"}

a.packages.select{|x|x.request.headers[:path].end_with?("api/batch")}

# list goes on ...

headers key name

Headers of both request and response have many fields.

package.request.headers is a hash. The keys is simply fields name of request header, but with a bit modification.

e.g.:

Accept          => :accept
Accept-Charset  => :accept_charset
Cookie          => :cookie
...

Same with response headers.

If a key(field) doesn't exist, it will be x.request.headers[:weird] = nil which is how hash works in Ruby.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/opensaz. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.