Skip to content

Commit

Permalink
Merge pull request olacabs#1 from superdaigo/dev
Browse files Browse the repository at this point in the history
Latest version
  • Loading branch information
superdaigo committed Jun 15, 2017
2 parents 81af23a + 5a41069 commit b72cd08
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 45 deletions.
8 changes: 4 additions & 4 deletions docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
docker-compose build
docker-compose up -d
docker-compose run web rake db:create
docker-compose run web rake db:migrate
docker-compose run -e APPLICATION_MODE=$1 web rake db:seed
docker-compose run web figlet -k -w 500 "JACKHAMMER IS UP"
docker-compose exec mysqldb sh -c 'while ! mysqladmin ping --silent; do sleep 1; done'
docker-compose exec web rake db:migrate
docker-compose run --rm -e APPLICATION_MODE=$1 web rake db:seed
docker-compose exec web figlet -k -w 500 "JACKHAMMER IS UP"
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ services:
container_name: jackhammer-db
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_DATABASE: jackhammer_production
ports:
- "3306:3306"
Expand All @@ -27,7 +25,7 @@ services:
- '.:/jackhammer'
ports:
- "5000:3000"
command: bash -c "mkdir -p tmp/pids && RAILS_ENV=production bundle exec rake db:migrate && RAILS_ENV=production bundle exec sidekiq -C config/sidekiq.yml -d && bundle exec puma -e production -b tcp://0.0.0.0:3000"
command: bash -c "bundle exec sidekiq -C config/sidekiq.yml -d && bundle exec puma -e production -b tcp://0.0.0.0:3000"
environment:
- REDIS_URL=redis://redis:6379
- SECRET_KEY_BASE=454ab84a2554a5e715db90c7560a06d8a20811d614e7313de05495ecdeac9614c4c3d263df1a5892b92d6c32ea06d4defbd2492c598e8295f89b8b316db25842
Expand Down
3 changes: 1 addition & 2 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ RUN apt-get install nmap -y

# add app
ADD app/ /home/app
WORKDIR /home/app
#create tmp dir
RUN mkdir -p tmp
RUN mkdir -p tmp/pids
RUN mkdir -p log/scans
WORKDIR /home/app
# expose HTTP
EXPOSE 3000
2 changes: 1 addition & 1 deletion web/app/app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def update
end
@user.update(is_team_lead?: @is_team_lead,name: params[:user][:name],is_admin?: @is_admin,is_security_member?: @is_security_member)
@user.repo_ids = params[:user][:repo_ids].select { |repo| repo.present? } if params[:user][:repo_ids].present?
@user.role_ids = params[:user][:role_ids].select { |role| role.present? } if params[:user][:role_ids].present?
@user.role_ids = params[:user][:role_ids] if params[:user][:role_ids].present?
selected_teams = params[:user][:team_ids].reject(&:blank?)
if selected_teams.present?
@user.team_ids = selected_teams
Expand Down
6 changes: 3 additions & 3 deletions web/app/app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
<li class="<%=current_class?('/analytics')%>"><%=link_to 'Analytics',analytics_path(analytics_type: AppConstants::OwnerTypes::CORPORATE)%></li>
<%end%>
<%end%>
<li class="<%=current_class?('/upload_scans/new')%>"><%=link_to 'ADD TARGET',add_target_scaners_path,method: :get%></li>
<li class="<%=current_class?('/scaners/add_target')%>"><%=link_to 'ADD TARGET',add_target_scaners_path,method: :get%></li>
<%if current_user.is_admin? || current_user.is_team_lead? || current_user.is_security_member?%>
<li> <%=link_to 'Upload Scan',new_upload_scan_path,method: :get%></li>
<%end%>
<li class="<%=current_class?('/upload_scans/new')%>"> <%=link_to 'Upload Scan',new_upload_scan_path,method: :get%></li>
<%end%>
<li class="<%=current_class?(@active_nav_class)%>"> <%=link_to "Scans",scaners_path(owner_type: get_owner_type,scan_type: AppConstants::ScanTypes::STATIC)%></li>
<%if !current_user.is_admin? && Setting.application_mode != AppConstants::UserMode::SINGLE_USER %>
<li class="<%=current_class?('/filters/apply_filter')%> dropdown">
Expand Down
1 change: 1 addition & 0 deletions web/app/app/views/scaners/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ $(document).ready(function() {
bServerSide: true,
processing: true,
bSort: false,
lengthMenu: [ [100, 200, 400, 1000], [100, 200, 400, 1000] ],
sAjaxSource: $('#target_list').data('source')
});
setInterval( function () {
Expand Down
12 changes: 6 additions & 6 deletions web/app/app/views/users/_update_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
</div>
<div class="form-group row">
<div class='col-md-6'>
<%prompt = 'select role'%>
<%=f.label :role,class: 'label-class'%>
<%= f.select :role_ids, options_for_select(Role.all.order(:name).collect { |t| [t.name,t.id]}.unshift(prompt), selected: prompt, disabled: prompt),{},{:class=> "form-control",'data-live-search'=>"true",'data-show-subtext'=> "true",'data-size'=>"5"}%>
<%= f.label :role,class: 'label-class'%>
<%= f.select(:role_ids, Role.all.order(:name).collect { |t| [t.name, t.id] }, {:include_blank => "select role"}, {:class=>"form-control", 'data-live-search'=>"true", 'data-show-subtext'=>"true", 'data-size' => "5"} )%>

</div>
</div>

<div class="form-group row">
<div class='col-md-6'>
<div class="checkbox checkbox-slider--b-flat">
<label>
<%=f.check_box :is_team_lead?,class: 'user-role' %><span class='label-class'>Is Team Lead?</span>
<%= f.check_box :is_team_lead?,class: 'user-role' %><span class='label-class'>Is Team Lead?</span>
</label>
</div>
</div>
<div class='col-md-6'>
<div class="checkbox checkbox-slider--b-flat">
<label>
<%=f.check_box :is_admin?,class: 'user-role' %><span class='label-class'>Is Admin?</span>
<%= f.check_box :is_admin?,class: 'user-role' %><span class='label-class'>Is Admin?</span>
</label>
</div>
</div>
Expand All @@ -52,7 +52,7 @@
<div class='col-md-6'>
<div class="checkbox checkbox-slider--b-flat">
<label>
<%=f.check_box :is_security_member?,class: 'user-role' %><span class='label-class'>Is Security Team?</span>
<%= f.check_box :is_security_member?,class: 'user-role' %><span class='label-class'>Is Security Team?</span>
</label>
</div>
</div>
Expand Down
56 changes: 30 additions & 26 deletions web/app/app/workers/github_pull_info_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class GithubPullInfoWorker
sidekiq_options unique: :while_executing
sidekiq_options({ :queue => :gitpull,:retry => 2 })
def perform
Octokit.auto_paginate = true
Dir.mkdir(Rails.root + "log/scans") unless File.exists?(Rails.root + "log/scans")
@logfile = File.open(Rails.root.join("log/scans/github_pull.log"), 'a')
raise StandardError,"Github details are not configured" unless Setting['github']
Expand All @@ -19,38 +20,41 @@ def perform
team = Team.find_or_create_by(name: git_team[:name])
@logfile.puts "pulling teams info of #{git_team[:name]}..and team id#{git_team[:id]}"
team_repos = client.team_repositories(git_team[:id])
team_repos.each do |project|
team_repos.each do |project|
repo = Repo.where(name: project[:name]).first_or_initialize.tap do |repo|
repo.ssh_repo_url = project[:clone_url]
repo.team = team
repo.git_type = "github"
repo.repo_type = "Static"
repo.save
end
branches = client.branches(project[:owner][:id])
repo_branches = repo.branches.map(&:name)
branches.each do |branch|
if repo_branches.include?(branch.name)
puts "#{branch.name} is existing..."
elsif branch[:name]!= 'gh-pages' && if branch[:name]!= 'v128'
branch = Branch.create!(name: branch.name,repo: repo)
puts "branch name....#{branch.name}"
else

begin
repo.ssh_repo_url = project[:clone_url]
repo.team = team
repo.git_type = "github"
repo.repo_type = "Static"
repo.save
end
begin
branches = client.branches(project[:full_name])
repo_branches = repo.branches.map(&:name)
branches.each do |branch|
if repo_branches.include?(branch.name)
puts "#{branch.name} is existing..."
elsif branch[:name]!= 'gh-pages' && branch[:name]!= 'v128'
branch = Branch.create!(name: branch.name,repo: repo)
puts "branch name....#{branch.name}"
end
end
rescue Octokit::NotFound => e
@logfile.puts "no branch: team:#{git_team[:name]} repo:#{project[:name]} #{e.inspect}"
end
end
end
rescue Exception=>e
@logfile.puts "Some exception is occured...#{e.inspect}"
end
rescue Exception=>e
@logfile.puts "Some exception is occured...#{e.inspect}"
end
AlertNotification.create(user_id: Setting['gitlab']['user_id'].to_i,identifier: 'task',alert_type: 'success',message: 'Pulling git info done!',task_name: "Git pull")
AlertNotification.create(user_id: Setting['gitlab']['user_id'].to_i,identifier: 'task',alert_type: 'success',message: 'Pulling git info done!',task_name: "Git pull")
end
@logfile.close
rescue StandardError => e
@logfile.puts e.message
AlertNotification.create(user_id: Setting['github']['user_id'].to_i,identifier: 'task',alert_type: 'danger',message: e.message,task_name: "Git pull")
@logfile.close
raise e
end
@logfile.puts e.message
AlertNotification.create(user_id: Setting['github']['user_id'].to_i,identifier: 'task',alert_type: 'danger',message: e.message,task_name: "Git pull")
@logfile.close
raise e
end
end

0 comments on commit b72cd08

Please sign in to comment.