codesake-commons 0.89.0 → 0.90.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/codesake/commons/version.rb +1 -1
- data/lib/codesake/{commons → core}/target.rb +25 -1
- data/lib/codesake/core/url.rb +77 -0
- data/lib/codesake-commons.rb +2 -0
- metadata +23 -14
- checksums.yaml +0 -7
@@ -1,10 +1,15 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'codesake/commons/logging'
|
3
|
+
|
1
4
|
module Codesake
|
2
|
-
module
|
5
|
+
module Core
|
3
6
|
class Target
|
4
7
|
attr_reader :url
|
5
8
|
attr_reader :username
|
6
9
|
attr_reader :password
|
7
10
|
|
11
|
+
attr_reader :page
|
12
|
+
|
8
13
|
|
9
14
|
# This will be fed by codesake-gengiscan
|
10
15
|
attr_reader :webserver
|
@@ -26,12 +31,31 @@ module Codesake
|
|
26
31
|
def initialize(options={})
|
27
32
|
$logger = Codesake::Commons::Logging.instance
|
28
33
|
@agent = Mechanize.new
|
34
|
+
@page = nil
|
29
35
|
|
30
36
|
@url ||= options[:url]
|
31
37
|
@username ||= options[:username]
|
32
38
|
@password ||= options[:password]
|
33
39
|
end
|
34
40
|
|
41
|
+
def has_page?
|
42
|
+
! @page.nil?
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_page(url = nil)
|
46
|
+
url = @url if url.nil?
|
47
|
+
|
48
|
+
begin
|
49
|
+
@page = @agent.get(url)
|
50
|
+
@cookies = @agent.cookies
|
51
|
+
rescue => e
|
52
|
+
$logger.err "get_page(): #{e.message}"
|
53
|
+
@page = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
@page
|
57
|
+
end
|
58
|
+
|
35
59
|
def is_alive?
|
36
60
|
return false unless url
|
37
61
|
return false unless @agent
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Codesake
|
2
|
+
module Core
|
3
|
+
class Url
|
4
|
+
|
5
|
+
attr_reader :url
|
6
|
+
attr_reader :base_url
|
7
|
+
attr_reader :params
|
8
|
+
attr_reader :original_params
|
9
|
+
|
10
|
+
def initialize(url)
|
11
|
+
@url = url
|
12
|
+
@params = []
|
13
|
+
@original_params = []
|
14
|
+
@base_url = url.split('?')[0]
|
15
|
+
if has_params?
|
16
|
+
p_array = url.split('?')[1].split('&')
|
17
|
+
p_array.each do |p|
|
18
|
+
pp = p.split('=')
|
19
|
+
param = {}
|
20
|
+
param[:name] = pp[0]
|
21
|
+
param[:value] = pp[1] unless pp[1].nil?
|
22
|
+
|
23
|
+
@params << param
|
24
|
+
@original_params << param.dup
|
25
|
+
end
|
26
|
+
@original_params.freeze
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"#{@base_url}?#{params_to_url}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def fuzz(name, value)
|
35
|
+
set(name, value)
|
36
|
+
"#{@base_url}?#{params_to_url}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def get(name)
|
40
|
+
value = nil
|
41
|
+
@params.each do |p|
|
42
|
+
value = p[:value] if p[:name] == name
|
43
|
+
end
|
44
|
+
value
|
45
|
+
end
|
46
|
+
|
47
|
+
def set(name, value)
|
48
|
+
@params.each do |p|
|
49
|
+
p[:value] = value if p[:name] == name
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def reset
|
54
|
+
@params = []
|
55
|
+
@original_params.each do |p|
|
56
|
+
@params << p.dup
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def has_params?
|
61
|
+
! @url.split('?')[1].nil?
|
62
|
+
end
|
63
|
+
def params_to_url
|
64
|
+
ret = ""
|
65
|
+
@params.each do |p|
|
66
|
+
ret += "#{p[:name]}=#{p[:value]}"
|
67
|
+
if !(p == @params.last)
|
68
|
+
ret +="&"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
ret
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
data/lib/codesake-commons.rb
CHANGED
metadata
CHANGED
@@ -1,55 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codesake-commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.90.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Paolo Perego
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rainbow
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: mechanize
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: nokogiri
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
description: codesake.com is an application security startup providing code review
|
@@ -74,33 +81,35 @@ files:
|
|
74
81
|
- lib/codesake-commons.rb
|
75
82
|
- lib/codesake/commons/io.rb
|
76
83
|
- lib/codesake/commons/logging.rb
|
77
|
-
- lib/codesake/commons/target.rb
|
78
84
|
- lib/codesake/commons/version.rb
|
85
|
+
- lib/codesake/core/target.rb
|
86
|
+
- lib/codesake/core/url.rb
|
79
87
|
- spec/codesake_commons_spec.rb
|
80
88
|
- spec/logging_spec.rb
|
81
89
|
- spec/spec_helper.rb
|
82
90
|
homepage: http://codesake.com
|
83
91
|
licenses: []
|
84
|
-
metadata: {}
|
85
92
|
post_install_message:
|
86
93
|
rdoc_options: []
|
87
94
|
require_paths:
|
88
95
|
- lib
|
89
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
90
98
|
requirements:
|
91
|
-
- - '>='
|
99
|
+
- - ! '>='
|
92
100
|
- !ruby/object:Gem::Version
|
93
101
|
version: '0'
|
94
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
95
104
|
requirements:
|
96
|
-
- - '>='
|
105
|
+
- - ! '>='
|
97
106
|
- !ruby/object:Gem::Version
|
98
107
|
version: '0'
|
99
108
|
requirements: []
|
100
109
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
110
|
+
rubygems_version: 1.8.25
|
102
111
|
signing_key:
|
103
|
-
specification_version:
|
112
|
+
specification_version: 3
|
104
113
|
summary: codesake_commons is the gem containing common ground routines useful across
|
105
114
|
the codesake.com project
|
106
115
|
test_files:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 7328c2346d57c68bc3abe8a58a9dffa6b6b9f7f8
|
4
|
-
data.tar.gz: 064907b7e12daa8d415a3f82bd6d034d348314d7
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 42f8865a54fa068fcfef189956df0c3bfe998d40a8f60512c4cb36da46323c6bdd71cfe223048a7ac22707724ca873755e3d450c9ff441f84864e8a70df45299
|
7
|
-
data.tar.gz: 19a6b0a0dc9541733cea36c288406b800cbbbe1b6e82080bcc6792c2212286dbe4120c6b6f93fe428c4da3056f874915eff46b2375a71678029f3038b5a08b8d
|