soh_cah_toa
9d4ea6c224
Fixed issue mentioned in FIXME comment in RubyDNS::Server#match.
...
Changed 'block.class.name' to just 'block' in case/when clause.
2013-07-22 22:42:27 -04:00
soh_cah_toa
b2aed14234
Added regex support to #add_rule (tests included).
...
Due to strange behavior in Sourcify, the /.../ literal syntax cannot
be used as a parameter; only %r{} or Regexp::new. There is a note
for this in the documentation for #add_rule.
2013-07-22 22:37:39 -04:00
soh_cah_toa
6a62cf9eaa
Added public attributes 'address' and 'port' to Dns::Server.
...
This removes the need to search config.yaml for the address:port.
Also included unit tests.
2013-07-19 22:33:40 -04:00
soh_cah_toa
8d961c1938
Added support for rules that fail to resolve (e.g. NXDOMAIN).
...
Included unit tests.
2013-07-19 22:15:25 -04:00
soh_cah_toa
141a12a92f
Included #remove_ruleset in public interface tests.
2013-07-17 18:19:56 -04:00
soh_cah_toa
95d0ddbe87
Added new method #remove_ruleset that clears the entire DNS ruleset.
...
Included unit tests as well.
2013-07-17 18:16:46 -04:00
soh_cah_toa
9cfb98963d
Added unit tests for #get_ruleset.
2013-07-16 23:48:46 -04:00
soh_cah_toa
94da775ba6
Added unit tests for #remove_rule (good and bad behavior).
2013-07-15 23:58:37 -04:00
soh_cah_toa
85d4375825
Added unit tests for #get_rule with an invalid id.
...
Also overrode Kernel#puts to suppress output from RubyDNS.
2013-07-15 23:36:29 -04:00
soh_cah_toa
4d0f58684f
Divided #add_rule tests into separate good and bad tests.
...
Also added unit tests that verify rule id format.
2013-07-15 23:07:06 -04:00
soh_cah_toa
8d95e6f522
Changed public interface tests to use #assert_respond_to.
...
This will improve the accuracy of potential error messages.
2013-07-15 18:25:33 -04:00
soh_cah_toa
5769615cd5
Added unit tests for #get_rule.
...
Also removed convenience variables from #add_rule tests (domain and
response). The "response" key in the hash returned by #get_rule is
generated by Sourcify which sourcifies the variable name, not its
value.
2013-07-15 03:48:01 -04:00
soh_cah_toa
9a4fd6cb4c
Removed "dns" task in Rakefile since "unit" is fine now.
2013-07-15 03:02:29 -04:00
soh_cah_toa
1ffa21d62a
Added unit tests for #add_rule.
...
These represent the first actual tests for the Dns::Server class.
2013-07-15 02:47:37 -04:00
soh_cah_toa
d8a8e37029
Moved DM adapter setup into first "test" method.
...
Since #setup is called between each test, the database table would
otherwise be cleared every time.
2013-07-15 02:39:41 -04:00
soh_cah_toa
8270abd2d5
Added unit tests for Dns::Server public interface.
2013-07-15 02:12:31 -04:00
soh_cah_toa
3865aab7ee
Added unit tests for required config.yaml settings.
2013-07-15 02:07:26 -04:00
soh_cah_toa
123c3cdc04
FIXED UNIT TEST ISSUES!!! \(^o^)/
...
Load path and configuration setup belong in #startup along with any
required files. DataMapper adapter connections go in #setup. That's
the secret recipe.
2013-07-15 02:00:12 -04:00
soh_cah_toa
ebbadba6dd
Improved #run_server to check if EM reactor is already running.
...
Also moved Thread creation to inside #run_server instead of
forcing caller to do so.
2013-07-14 23:27:21 -04:00
soh_cah_toa
d9f7af2721
Reference point for broken unit tests.
...
NoMethodError and NameError are present.
2013-06-22 03:32:42 -04:00
soh_cah_toa
d45bff3a59
Improved #check_dns_response to use config file for address/port.
2013-06-10 18:11:36 -04:00
soh_cah_toa
d2ac9e0f7a
Included broken DNS unit tests so others can help debug.
...
Temporary 'dns' and 'dns_rest' Rake tasks make it easier to run tests.
2013-06-08 23:25:23 -04:00
soh_cah_toa
9e1ec69e40
Added tests for GET /api/dns/ruleset handler.
2013-06-08 22:44:51 -04:00
soh_cah_toa
e775748603
Added more tests for GET /api/dns/rule/:id with invalid input.
...
Also changed handler to return 404 when rule isn't found.
2013-06-08 21:58:28 -04:00
soh_cah_toa
3b58518cfd
Added tests for GET /api/dns/rule/:id handler.
...
Fixed #parse_response so that these tests pass.
2013-06-08 19:04:42 -04:00
soh_cah_toa
b9d64f0b89
Significantly refactored code in #test_3_add_rule_types.
2013-06-07 23:56:19 -04:00
soh_cah_toa
e527f1ae09
Refactored redundant code in #test_1_add_rule_good.
2013-06-07 23:09:07 -04:00
soh_cah_toa
68e56fa8c0
Added tests for NS, PTR, SOA, TXT, WKS, and invalid RR types.
...
All RR's are now tested. Though the tests are yet to be optimized.
2013-06-07 23:03:10 -04:00
soh_cah_toa
eccbdd6958
Added tests for AAAA, CNAME, HINFO, MINFO, and MX RR types.
...
Also fixed #format_response to properly format MS records.
2013-06-07 18:32:29 -04:00
soh_cah_toa
019ec2f6ed
Added new test for attempting to add an existing rule.
2013-06-07 00:05:15 -04:00
soh_cah_toa
cfa9177af1
Added 4 new tests for bad POST /api/dns/rule requests.
2013-06-06 23:58:12 -04:00
soh_cah_toa
1f37ceec9f
Began first integration tests for DNS RESTful API interface.
...
First test is for POST /api/dns/rule handler.
2013-06-06 23:16:40 -04:00
soh_cah_toa
6901581ae7
Moved #format_response call to before when RR type is evaled.
...
Since #format_response throws an exception for unknown RR types,
calling it first will ensure bad Resolv::DNS::Resource names will
never be evaled.
2013-06-06 22:59:54 -04:00
soh_cah_toa
09ec09601e
Changed hash key syntax from previous commit.
...
Besides being consistent, Sinatra actually requires the string
syntax.
2013-06-05 18:33:08 -04:00
soh_cah_toa
fc6f0aface
Changed DELETE handler to return JSON "success" key.
...
Prior to this, nothing was returned. This will allow users to
determine whether or not a rule was removed as expected.
2013-06-05 18:29:18 -04:00
soh_cah_toa
89a5d6fdbb
Modified #remove_rule to return a boolean value.
...
This is will soon allow the DELETE handler to indicate success
or failure.
2013-06-05 18:20:48 -04:00
soh_cah_toa
6c61b39d81
Changed 401 status to 403 in filter for non-permitted IP's.
...
403 Forbidden is more appropriate since 401 Unauthorized only
indicates that authentication is needed. In the case of a bad IP,
authentication will make no difference which is exactly what 403 is
meant for.
2013-06-05 17:09:09 -04:00
soh_cah_toa
80ab665054
Added new InvalidParamError class for handling bad named parameters.
...
Previously, InvalidJsonError was being used mistakenly for this which
is misleading considering no JSON was involved.
2013-06-05 16:56:05 -04:00
soh_cah_toa
e56494d486
Renamed /rules GET route to /ruleset for the sake of consistency.
...
Also added new "count" key to result that lists the number of rules.
2013-06-05 16:30:24 -04:00
soh_cah_toa
2f5133e11a
Changed GET handlers to return recently fixed rule data.
...
Also wrapped all handlers in a begin/end block that catches
internal StandardError exceptions.
2013-06-05 15:56:33 -04:00
soh_cah_toa
fce4c9196d
Modified grep test case to allow #eval use in DNS extension.
...
Using #eval is necessary for normal functioning and is now used in
a safe manner.
2013-06-03 21:53:06 -04:00
soh_cah_toa
0af4029915
Added placeholders necessary to start DNS unit tests.
...
Currently does nothing but assert(true).
2013-06-03 21:42:34 -04:00
soh_cah_toa
44622345d0
s/DNS/Dns/g since that is the BeEF style convention.
2013-06-03 17:55:58 -04:00
soh_cah_toa
0f8221918b
Improved coding style (a la ruby-style-guide and rubocop).
...
Because I'm too tired to start testing and need a little victory. ;)
2013-06-03 00:11:41 -04:00
soh_cah_toa
c8c9e1e139
Reimplemented POST handler to avoid unsafe use of #eval.
...
Now the desired response is passed an array. Each RR type is handled
specially to craft the necessary response.
2013-06-02 22:40:58 -04:00
soh_cah_toa
998980b566
Fixed case-statement in #match that prevented adding rules locally.
2013-06-02 22:23:27 -04:00
soh_cah_toa
7f4562945a
Added new InvalidJsonError class for handling errors in JSON input.
...
This is better practice than just (ab)using StandardError.
2013-05-26 23:46:37 -04:00
soh_cah_toa
38284d5eaa
Implemented DELETE handler for removing DNS rules.
2013-05-26 23:26:58 -04:00
soh_cah_toa
27b1b530ef
Implemented POST handler for /api/dns/rule which adds a new rule.
...
A host of other changes got roped into this as well. #match now
silently handles blocks passed as a String in order to handle
the 'block' JSON parameter. This is because sourcify doesn't
work with eval'd data.
Rule id's are no longer incremental integers. It's now a 7-character
"token" generated from #secure_token and is managed by the RubyDNS
module.
2013-05-26 22:44:11 -04:00
soh_cah_toa
c6f38324d1
Refactored #get_ruleset to be part of RubyDNS.
...
All database logic should be inside RubyDNS since BeEF's DNS class
is mostly just a wrapper around it.
2013-05-18 21:00:22 -04:00