Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect if a website is using an open source framework #59

Merged
merged 1 commit into from
Aug 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/site-inspector/checks/sniffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ class SiteInspector
class Endpoint
class Sniffer < Check

OPEN_SOURCE_FRAMEWORKS = [
# Sniffles
:drupal,
:joomla,
:movabletype,
:phpbb,
:wordpress,

# Internal
:php,
:expression_engine
]

def framework
cms = sniff :cms
return cms unless cms.nil?
Expand All @@ -10,6 +23,10 @@ def framework
nil
end

def open_source?
OPEN_SOURCE_FRAMEWORKS.include?(framework)
end

def analytics
sniff :analytics
end
Expand Down
11 changes: 11 additions & 0 deletions spec/checks/site_inspector_endpoint_sniffer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def set_cookie(key, value)
it "detects advertising" do
expect(subject.advertising).to eql(:adsense)
end

it "knows wordpress is open source" do
expect(subject.open_source?).to eql(true)
end
end

context "no body" do
Expand All @@ -83,14 +87,21 @@ def set_cookie(key, value)
SiteInspector::Endpoint::Sniffer.new(endpoint)
end

it "knows when something isn't open source" do
set_cookie("foo", "bar")
expect(subject.open_source?).to eql(false)
end

it "detects PHP" do
set_cookie("PHPSESSID", "1234")
expect(subject.framework).to eql(:php)
expect(subject.open_source?).to eql(true)
end

it "detects Expression Engine" do
set_cookie("exp_csrf_token", "1234")
expect(subject.framework).to eql(:expression_engine)
expect(subject.open_source?).to eql(true)
end
end
end