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

Remove dead code #806

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

user12986714
Copy link
Contributor

This PR tries to remove code that is no longer in use.

Copy link
Member

@thesecretmaster thesecretmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to also keep some of the dumps code, although it's dead now, it may be alive again if we move off of Thomas's infra.

Comment on lines -87 to -98
def check_token
token = SmokeDetector.where(access_token: params[:token]).first
payload = {
exists: token.present?,
owner_name: token&.user&.username,
location: token&.location,
created_at: token&.created_at,
updated_at: token&.updated_at
}

render json: payload
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget when this was introduced, but I think we will want to keep this unless helios is official dead.

app/views/dashboard/index.html.erb Outdated Show resolved Hide resolved
@user12986714
Copy link
Contributor Author

user12986714 commented Sep 7, 2020

I'd like to also keep some of the dumps code, although it's dead now, it may be alive again if we move off of Thomas's infra.

Well, the point being the code is originally bugged for performance and security, so if we move away from the infra we have to rewrite them anyway.

@ArtOfCode-
Copy link
Member

A lot of this seems like stuff that's potentially still alive/useful. Could you add a comment to each of the files changed to explain what the rationale for considering it dead is?

@@ -2,7 +2,6 @@

class APIController < ApplicationController
before_action :verify_key, except: %i[filter_generator api_docs filter_fields calculate_filter]
before_action :verify_trusted_key, only: [:regex_search]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method has been deleted long before.

@@ -1,8 +1,6 @@
# frozen_string_literal: true

class DumpsController < ApplicationController
before_action :set_dump, only: %i[show edit update destroy]

Copy link
Contributor Author

@user12986714 user12986714 Sep 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The four methods in only clause does not exist.

before_action :verify_blacklist_manager, only: %i[force_failover force_pull]
before_action :verify_smoke_detector_runner, only: %i[mine token_regen new create]
before_action :set_smoke_detector, except: %i[audits mine new create check_token]
before_action :set_smoke_detector, except: %i[audits mine new create]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Helios is still active but this may need to be reverted.

@@ -45,25 +45,6 @@ onLoad(() => {
});
});

$('input.pin-checkbox').change(function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned roles are indistinguishable from non-pinned roles.

sanitized = sanitize_for_search term, **cols
select(Arel.sql("`#{table_name}`.*, #{sanitized} AS search_score"))
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is never used.

app/models/user.rb Outdated Show resolved Hide resolved
def has_pinned_role?(role)
UsersRole.where(user: self, role: Role.find_by(name: role), pinned: true).exists?
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indistinguishable

<%= form_tag migrate_token_path do %>
<%= hidden_field_tag "state", params[:state] %>
<%= submit_tag "Confirm that you've granted access", class: 'btn btn-primary' %>
<% end %>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is no longer being linked to, and I think all token migration is finished.

class DropTableDumps < ActiveRecord::Migration[5.2]
def change
execute 'DROP TABLE dumps'
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table no longer being used after Rails based full dump being disabled.

class RemoveAPITokenLegacy < ActiveRecord::Migration[5.2]
def change
remove_column :users, :encrypted_api_token_legacy
remove_column :users, :token_migrated_legacy
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy column; may introduce security risks.

app/models/application_record.rb Outdated Show resolved Hide resolved
app/models/post.rb Outdated Show resolved Hide resolved
app/models/user.rb Outdated Show resolved Hide resolved
@thesecretmaster
Copy link
Member

This all looks good to me, but I want to get confirmation as to Helios being officially dead yet. I feel like it's still a thing we want to make happen eventually?

@user12986714
Copy link
Contributor Author

This all looks good to me, but I want to get confirmation as to Helios being officially dead yet. I feel like it's still a thing we want to make happen eventually?

Well, Helios is archived and is way out dated. It is highly unlikely that the original project will become active again. Although we do want that kind of change, it is likely that we need to rewrite it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants