mysqlaudit 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/bin/mysqlaudit +42 -25
- data/lib/mysqlaudit/audit.rb +1 -0
- data/lib/mysqlaudit/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
data/bin/mysqlaudit
CHANGED
@@ -17,24 +17,30 @@ program :help, 'Author', 'Nicola Strappazzon <nicola51980@gmail.com>'
|
|
17
17
|
|
18
18
|
command :install do |c|
|
19
19
|
c.description = 'Install audit table'
|
20
|
-
c.syntax = '
|
20
|
+
c.syntax = 'mysqlaudit install --host 127.0.0.1 --user root [--pass admin] --schema sakila [--table foo]'
|
21
21
|
c.option '--host STRING', String, 'Host'
|
22
22
|
c.option '--user STRING', String, 'User'
|
23
23
|
c.option '--pass STRING', String, 'Password'
|
24
24
|
c.option '--schema STRING', String, 'Schema name'
|
25
25
|
c.option '--table STRING', String, 'Table name'
|
26
26
|
c.action do |args, options|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
if options.host.nil? ||
|
28
|
+
options.user.nil? ||
|
29
|
+
options.schema.nil?
|
30
|
+
puts c.syntax
|
31
|
+
else
|
32
|
+
Mysqlaudit::Actions.new({host: options.host,
|
33
|
+
user: options.user,
|
34
|
+
password: options.pass,
|
35
|
+
schema: options.schema,
|
36
|
+
table: options.table}).install
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
35
41
|
command :uninstall do |c|
|
36
42
|
c.description = 'Uninstall audit table'
|
37
|
-
c.syntax = '
|
43
|
+
c.syntax = 'mysqlaudit uninstall --host 127.0.0.1 --user root [--pass admin] --schema sakila [--table foo] [--[no-]drop-audit-table]'
|
38
44
|
c.option '--host STRING', String, 'Host'
|
39
45
|
c.option '--user STRING', String, 'User'
|
40
46
|
c.option '--pass STRING', String, 'Password'
|
@@ -42,18 +48,24 @@ command :uninstall do |c|
|
|
42
48
|
c.option '--table STRING', String, 'Table name'
|
43
49
|
c.option '--[no-]drop-audit-table', 'Drop audit table'
|
44
50
|
c.action do |args, options|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
+
if options.host.nil? ||
|
52
|
+
options.user.nil? ||
|
53
|
+
options.schema.nil?
|
54
|
+
puts c.syntax
|
55
|
+
else
|
56
|
+
Mysqlaudit::Actions.new({host: options.host,
|
57
|
+
user: options.user,
|
58
|
+
password: options.pass,
|
59
|
+
schema: options.schema,
|
60
|
+
table: options.table,
|
61
|
+
drop: options.drop_audit_table}).uninstall
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
53
65
|
|
54
66
|
command :rollback do |c|
|
55
67
|
c.description = 'Rollback transaction cath in audit table'
|
56
|
-
c.syntax = '
|
68
|
+
c.syntax = 'mysqlaudit rollback --host 127.0.0.1 --user root [--pass admin] --schema sakila --table foo [--statement all|insert|update|delete]'
|
57
69
|
c.option '--host STRING', String, 'Host'
|
58
70
|
c.option '--user STRING', String, 'User'
|
59
71
|
c.option '--pass STRING', String, 'Password'
|
@@ -61,19 +73,24 @@ command :rollback do |c|
|
|
61
73
|
c.option '--table STRING', String, 'Table name'
|
62
74
|
c.option '--statement STRING', String, 'Statement operation: all, insert, update, delete'
|
63
75
|
c.action do |args, options|
|
64
|
-
|
65
|
-
options.statement = :all
|
66
|
-
end
|
76
|
+
options.default statement: :all
|
67
77
|
|
68
|
-
if
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
table: options.table,
|
74
|
-
statement: options.statement.to_sym}).rollback
|
78
|
+
if options.host.nil? ||
|
79
|
+
options.user.nil? ||
|
80
|
+
options.schema.nil? ||
|
81
|
+
options.table.nil?
|
82
|
+
puts c.syntax
|
75
83
|
else
|
76
|
-
|
84
|
+
if [:all, :insert, :update, :delete].include? options.statement.to_sym
|
85
|
+
Mysqlaudit::Actions.new({host: options.host,
|
86
|
+
user: options.user,
|
87
|
+
password: options.pass,
|
88
|
+
schema: options.schema,
|
89
|
+
table: options.table,
|
90
|
+
statement: options.statement.to_sym}).rollback
|
91
|
+
else
|
92
|
+
puts "Invalid values on argument: --statement."
|
93
|
+
end
|
77
94
|
end
|
78
95
|
end
|
79
96
|
end
|
data/lib/mysqlaudit/audit.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'mysql2'
|
3
3
|
|
4
4
|
# @todo Optimize passing params on methods with maps.
|
5
|
+
# @todo Add in rollback comment the name of database.
|
5
6
|
# @todo Optimize is set params to execute methods.
|
6
7
|
# @todo Passing as parameter the tables names to apply triggers.
|
7
8
|
# @todo Change name for audit table.
|
data/lib/mysqlaudit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysqlaudit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: MySQL tool for audit all tables with triggers.
|
15
15
|
email: nicola51980@gmail.com
|