Class: Vcsmap::Plugin::WordpressConfig

Inherits:
BasePlugin
  • Object
show all
Defined in:
lib/vcsmap/plugins/wordpress_config.rb

Instance Attribute Summary

Attributes inherited from BasePlugin

#search_string

Instance Method Summary collapse

Methods inherited from BasePlugin

#capture_match

Constructor Details

#initializeWordpressConfig

Returns a new instance of WordpressConfig.



4
5
6
7
8
9
10
# File 'lib/vcsmap/plugins/wordpress_config.rb', line 4

def initialize
  @search_string = 'filename:wp-config.php+DB_PASSWORD'
  @host_regex = /(?:\'|\")DB_HOST(?:\'|\")\,(?:\ |)(?:\'|\")(.*?)(?:\'|\")/i
  @username_regex = /(?:\'|\")DB_USER(?:\'|\")\,(?:\ |)(?:\'|\")(.*?)(?:\'|\")/i
  @password_regex = /(?:\'|\")DB_PASSWORD(?:\'|\")\,(?:\ |)(?:\'|\")(.*?)(?:\'|\")/i
  @database_regex = /(?:\'|\")DB_NAME(?:\'|\")\,(?:\ |)(?:\'|\")(.*?)(?:\'|\")/i
end

Instance Method Details

#credentials(file) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/vcsmap/plugins/wordpress_config.rb', line 12

def credentials(file)
  @host = capture_match(@host_regex, file)
  @user = capture_match(@username_regex, file)
  @pass = capture_match(@password_regex, file)
  @database = capture_match(@database_regex, file)
  ['MySQL', @host, @user, @pass, @database]
rescue NoMethodError
  []
end

#table_headerObject



22
23
24
# File 'lib/vcsmap/plugins/wordpress_config.rb', line 22

def table_header
  %w(Protocol Host Username Password Database)
end