diff --git a/ManageIQ/all.rb b/ManageIQ/all.rb new file mode 100644 index 0000000..733dc5b --- /dev/null +++ b/ManageIQ/all.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +ENV['RAILS_ENV'] = 'development' + +require '../manageiq/config/environment' + +#in miq-ui-classic ls | grep "controller.rb" | cut -d '.' -f 1 +all_controllers = `ls app/controllers/ | grep "controller.rb" | cut -d '.' -f1`.split("\n") + +whitelist = [] + +all_controllers.each do |controller_name| + break if controller_name == "oauth_sessions_controller" + controller = controller_name.classify.constantize + buttons = controller.constants.select{|x| x.to_s.include?("ALLOWED_ACTIONS")} + break unless buttons.present? + buttons.each do |button| + whitelist.concat(controller.const_get(button).keys) + end +end +whitelist.sort.uniq.each { |item| puts item } diff --git a/ManageIQ/dead_methods.sh b/ManageIQ/dead_methods.sh new file mode 100644 index 0000000..ad23787 --- /dev/null +++ b/ManageIQ/dead_methods.sh @@ -0,0 +1,42 @@ +#!/bin/bash +#all temp files +ROUTES=`mktemp` +ALLOWEDMETHODS=`mktemp` +OLD=`mktemp` +NEW=`mktemp` + +#in miq get routes +bundle exec rake routes | ag "\s#*([\S]+)$" -o | ag '(?<=#).*' -o > "$ROUTES" +echo "routes DONE" + +#in miq-ui +cd .. +cd manageiq-ui-classic +echo "moved to miq-ui-classic" + +if [[ -n $0 ]]; then + git checkout $0 + bin/update +fi +ruby /Users/zita/Desktop/all.rb > "$ALLOWEDMETHODS" +sed -i "" '/^\*/ d' "$ALLOWEDMETHODS" + +echo "extra methods DONE" + +debride --rails app/ --whitelist "$ROUTES" "$ALLOWEDMETHODS" | cut -d ":" -f1 > "$OLD" + +echo "old possibly dead methods DONE" + +if [[ -n $1 ]]; then + git checkout $1 + bin/update + ruby /Users/zita/Desktop/all.rb > "$ALLOWEDMETHODS" + sed -i "" '/^\*/ d' "$ALLOWEDMETHODS" + debride --rails app/ --whitelist "$ROUTES" "$ALLOWEDMETHODS" | cut -d ":" -f1 > "$NEW" + echo "ALL DEFFERENCES" + diff -Naur "$OLD" "$NEW" +else + cat "$OLD" | while read line; do + echo "$line" + done +fi