codesake-commons 0.83.3 → 0.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 45ee0b2bb6bbda3237106c71f4810f5b449cf3df
4
+ data.tar.gz: 3116c83b1a4917cb480e44e5b1e2630c31be202b
5
+ SHA512:
6
+ metadata.gz: 3a42acfa2e004151437e76bea03220dcd1764d2e609864581c322bf307717700e13071592e8ea2f2a42e4c04f55f85a0612caa1d5761d252699cab918282fa8e
7
+ data.tar.gz: eafc1e44e50699a3c705e9c3a9db35b85eb76d919182a331f9fb58774d8197a70bcc4ed99c426f5f788c027431b831e742e902dca321697aeaebbacbffab4fd3
data/README.md CHANGED
@@ -1,12 +1,17 @@
1
- # CodesakeCommons
1
+ # Codesake::Commons
2
+
3
+ ```Codesake::Commons``` is the common framework under the codesake.com project.
4
+ It defines core data structure, logging facilities and all other stuff needed by:
5
+
6
+ * codesake-dusk
7
+ * codesake-dawn
2
8
 
3
- TODO: Write a gem description
4
9
 
5
10
  ## Installation
6
11
 
7
12
  Add this line to your application's Gemfile:
8
13
 
9
- gem 'codesake_commons'
14
+ gem 'codesake-commons'
10
15
 
11
16
  And then execute:
12
17
 
@@ -14,11 +19,14 @@ And then execute:
14
19
 
15
20
  Or install it yourself as:
16
21
 
17
- $ gem install codesake_commons
22
+ $ gem install codesake-commons
18
23
 
19
24
  ## Usage
20
25
 
21
- TODO: Write usage instructions here
26
+ ### Using Codesake::Commons::Target
27
+
28
+ ```Codesake::Commons::Target``` is intended to be the code object containing
29
+ all the information a security specialist needs during his activity.
22
30
 
23
31
  ## Contributing
24
32
 
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency 'rainbow'
21
+ gem.add_dependency 'mechanize'
22
+ gem.add_dependency 'nokogiri'
21
23
  end
@@ -7,10 +7,11 @@ module Codesake
7
7
  class Logging
8
8
  include Singleton
9
9
 
10
- attr_reader :silencer
11
- attr_reader :verbose
12
- attr_reader :syslog
10
+ attr_reader :silencer
11
+ attr_reader :verbose
12
+ attr_reader :syslog
13
13
  attr_accessor :filename
14
+ attr_reader :component
14
15
 
15
16
  def initialize
16
17
  super
@@ -18,10 +19,11 @@ module Codesake
18
19
  @verbose = true
19
20
  @syslog = true
20
21
  @filename = nil
22
+ @component = ""
21
23
  end
22
24
 
23
25
  def die(msg, pid_file=nil)
24
- STDERR.print "#{Time.now.strftime("%H:%M:%S")} [!] #{msg}\n".color(:red)
26
+ STDERR.print "#{Time.now.strftime("%H:%M:%S")} [!] [#{@component}]: #{msg}\n".color(:red)
25
27
  send_to_syslog(msg, :helo)
26
28
  send_to_file(msg, :helo)
27
29
  Codesake::Commons::Io.remove_pid_file(pid_file) unless pid_file.nil?
@@ -29,37 +31,46 @@ module Codesake
29
31
  end
30
32
 
31
33
  def err(msg)
32
- STDERR.print "#{Time.now.strftime("%H:%M:%S")} [!] #{msg}\n".color(:red)
34
+ STDERR.print "#{Time.now.strftime("%H:%M:%S")} [!] [#{@component}]: #{msg}\n".color(:red)
33
35
  send_to_syslog(msg, :err)
34
36
  send_to_file(msg, :err)
35
37
  end
36
38
 
37
39
  def warn(msg)
38
- STDOUT.print "#{Time.now.strftime("%H:%M:%S")} [!] #{msg}\n".color(:yellow)
40
+ STDOUT.print "#{Time.now.strftime("%H:%M:%S")} [!] [#{@component}]: #{msg}\n".color(:yellow)
39
41
  send_to_syslog(msg, :warn)
40
42
  send_to_file(msg, :warn)
41
43
  end
42
44
 
43
45
  def ok(msg)
44
- STDOUT.print "#{Time.now.strftime("%H:%M:%S")} [*] #{msg}\n".color(:green)
46
+ STDOUT.print "#{Time.now.strftime("%H:%M:%S")} [*] [#{@component}]: #{msg}\n".color(:green)
45
47
  send_to_syslog(msg, :log)
46
48
  send_to_file(msg, :log)
47
49
  end
48
50
 
49
51
  def log(msg)
50
52
  return if @silencer
51
- STDOUT.print "#{Time.now.strftime("%H:%M:%S")}: #{msg}\n".color(:white)
53
+ STDOUT.print "#{Time.now.strftime("%H:%M:%S")}: [#{@component}]: #{msg}\n".color(:white)
52
54
  send_to_syslog(msg, :log)
53
55
  send_to_file(msg, :log)
54
56
  end
55
57
 
56
- def helo(msg, pid_file = nil)
57
- STDOUT.print "[*] #{msg} at #{Time.now.strftime("%H:%M:%S")}\n".color(:white)
58
- send_to_syslog(msg, :helo)
59
- send_to_file(msg, :helo)
58
+ def helo(component, version, pid_file = nil)
59
+ @component = component
60
+ STDOUT.print "[*] #{@component} v#{version} is starting up at #{Time.now.strftime("%H:%M:%S")}\n".color(:white)
61
+ send_to_syslog("#{@component} v#{version} is starting up", :helo)
62
+ send_to_file("#{@component} v#{version} is starting up", :helo)
60
63
  Codesake::Commons::Io.create_pid_file(pid_file) unless pid_file.nil?
61
64
  end
62
65
 
66
+ def bye(component, version, pid_file = nil)
67
+ @component = component
68
+ STDOUT.print "[*] #{@component} is leaving at #{Time.now.strftime("%H:%M:%S")}\n".color(:white)
69
+ send_to_syslog("#{@component} is leaving", :helo)
70
+ send_to_file("#{@component} is leaving", :helo)
71
+ Codesake::Commons::Io.remove_pid_file(pid_file) unless pid_file.nil?
72
+ end
73
+
63
74
  def toggle_silence
64
75
  @silencer = ! @silencer
65
76
  @verbose = ! @silencer
@@ -0,0 +1,48 @@
1
+ module Codesake
2
+ module Commons
3
+ class Target
4
+ attr_reader :url
5
+ attr_reader :username
6
+ attr_reader :password
7
+
8
+
9
+ # This will be fed by codesake-gengiscan
10
+ attr_reader :webserver
11
+ attr_reader :language
12
+ attr_reader :cms
13
+
14
+ # This is the website tree. Fed by codesake-links.
15
+ # Each tree element is an hash like
16
+ # {:url, :code, :kind, :dynamic} :dynamic is true or false if the page
17
+ # has some dynamic content that needs to be exploited (url parameters,
18
+ # forms, ...)
19
+ attr_reader :site_tree
20
+
21
+ attr_reader :cookies
22
+
23
+ attr_reader :score
24
+ attr_reader :vulns
25
+
26
+ def initialize(options={})
27
+ $logger = Codesake::Commons::Logging.instance
28
+ @agent = Mechanize.new
29
+
30
+ @url ||= options[:url]
31
+ @username ||= options[:username]
32
+ @password ||= options[:password]
33
+ end
34
+
35
+ def is_alive?
36
+ return false unless url
37
+ return false unless @agent
38
+
39
+ begin
40
+ @agent.get('/')
41
+ return true
42
+ rescue Net::HTTP::Persistent::Error=>e
43
+ return false
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,5 +1,5 @@
1
1
  module Codesake
2
2
  module Commons
3
- VERSION = "0.83.3"
3
+ VERSION = "0.85.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,30 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codesake-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.83.3
5
- prerelease:
4
+ version: 0.85.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Paolo Perego
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-11 00:00:00.000000000 Z
11
+ date: 2013-10-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rainbow
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mechanize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
28
53
  - !ruby/object:Gem::Version
29
54
  version: '0'
30
55
  description: codesake.com is an application security startup providing code review
@@ -49,33 +74,33 @@ files:
49
74
  - lib/codesake-commons.rb
50
75
  - lib/codesake/commons/io.rb
51
76
  - lib/codesake/commons/logging.rb
77
+ - lib/codesake/commons/target.rb
52
78
  - lib/codesake/commons/version.rb
53
79
  - spec/codesake_commons_spec.rb
54
80
  - spec/logging_spec.rb
55
81
  - spec/spec_helper.rb
56
82
  homepage: http://codesake.com
57
83
  licenses: []
84
+ metadata: {}
58
85
  post_install_message:
59
86
  rdoc_options: []
60
87
  require_paths:
61
88
  - lib
62
89
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
90
  requirements:
65
- - - ! '>='
91
+ - - '>='
66
92
  - !ruby/object:Gem::Version
67
93
  version: '0'
68
94
  required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
95
  requirements:
71
- - - ! '>='
96
+ - - '>='
72
97
  - !ruby/object:Gem::Version
73
98
  version: '0'
74
99
  requirements: []
75
100
  rubyforge_project:
76
- rubygems_version: 1.8.25
101
+ rubygems_version: 2.0.4
77
102
  signing_key:
78
- specification_version: 3
103
+ specification_version: 4
79
104
  summary: codesake_commons is the gem containing common ground routines useful across
80
105
  the codesake.com project
81
106
  test_files: