-
Notifications
You must be signed in to change notification settings - Fork 29
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
multi-category challenge / tags support #122
Comments
This would require a pretty decent change to the core structure of how the scoreboard is structured. We normally just choose the category that seems most relevant and mention in the description if it overlaps with another category. The easiest way to do this would probably be just allow a challenge to have many categories. That being said I think this is a bit out of scope of how we normally use the scoreboard, not to say we wouldn't consider a PR for this. |
Maybe an in between solution with fewer changes is:
|
I am not personally opposed to just changing the default view of the scoreboard to have an overall more descriptive design such as the one from the 2014 ASIS CTF. That is probably the easiest route to take since it really requires minimal backend work and a frontend redesign. Redesigning the table to show a title, point value and tags is a pretty decent option. |
Tags should work exactly the same way as categories but with multiple value support. And yes changes in the game view. I'm afraid I won't be helpful as I'm unskilled in Rails or web app design right now. This may change in the future when I'll begin to learn RoR. PS : let me know if I can help in any way. |
I find a way to easy do that with filtrify.
That sounds clean and easy. |
Running create_table "challenges_categories", primary_key: ["challenge_id", "category_id"], force: :cascade do |t|
t.integer "challenge_id", null: false
t.integer "category_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end in But I see that active record is not automatically adding foreign keys. I'm not sure how to add them. https://edgeguides.rubyonrails.org/active_record_migrations.html#foreign-keys I really want to help for this issue but I'm not a dev, so if someone can help me? |
Rails generators are probably your friend here: https://stackoverflow.com/questions/39937839/add-a-reference-column-migration-in-rails-5/39937840 Also if you look through our old migrations, some will probably come in handy: https://github.com/mitre-cyber-academy/ctf-scoreboard/blob/master/db/migrate/20170510052137_add_division_to_teams.rb |
I ran so it created As I see in That was later confirmed:
So I modified the migration in: class CreateChallengesCategories < ActiveRecord::Migration[5.1]
def change
create_table :challenges_categories, primary_key: ["challenge_id", "category_id"], force: :cascade do |t|
t.integer :challenge_id, null: false
t.integer :category_id, null: false
t.datetime :created_at, null: false
t.datetime :updated_at, null: false
t.references :challenges_categories, :challenges, foreign_key: true
t.references :challenges_categories, :categories, foreign_key: true
end
end
end Then I had error running Then I saw that Then I read https://edgeguides.rubyonrails.org/active_record_migrations.html#changing-existing-migrations. So instead of changing existing migrations, I'll create a new one to do the change. So I followed https://edgeguides.rubyonrails.org/active_record_migrations.html#foreign-keys So I ran class AddChallengeRefToChallengesCategories < ActiveRecord::Migration[5.1]
def change
add_reference :challenges_categories, :challenges, foreign_key: true
end
end and class AddCategoryRefToChallengesCategories < ActiveRecord::Migration[5.1]
def change
add_reference :challenges_categories, :categories, foreign_key: true
end
end Finally I ran
Finally thanks to DBeaver I checked and saw that the proper FK were added to So checking again create_table "challenges_categories", primary_key: ["challenge_id", "category_id"], force: :cascade do |t|
t.integer "challenge_id", null: false
t.integer "category_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "challenges_id"
t.bigint "categories_id"
t.index ["categories_id"], name: "index_challenges_categories_on_categories_id"
t.index ["challenges_id"], name: "index_challenges_categories_on_challenges_id"
end
[...]
add_foreign_key "challenges_categories", "categories", column: "categories_id"
add_foreign_key "challenges_categories", "challenges", column: "challenges_id" But that's wrong because rails is unaware of plurals between So from here https://edgeguides.rubyonrails.org/active_record_migrations.html#changing-existing-migrations, I saw I add to run
Then I manually modified the two wrong migrations. Thx to teh doc:
I had to read https://api.rubyonrails.org/v5.1/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_reference So I tried again with: class AddChallengeRefToChallengesCategories < ActiveRecord::Migration[5.1]
def change
add_reference :challenges_categories, :challenge, foreign_key: {to_table: :challenges}
end
end and class AddCategoryRefToChallengesCategories < ActiveRecord::Migration[5.1]
def change
add_reference :challenges_categories, :category, foreign_key: {to_table: :categories}
end
end But I get So I need to 1) add only a reference only, not create the column and the reference or 2) rollback again and modify my I did a mix of both, I rollbacked, create normal columns, and then used Then with dbeaver I generated mock data randomly and they all respected the constraints. I think I'm good to publish the database change for this feature. |
I created the new rails migrations to reflect the database changes needed for the multi-category feature see mitre-cyber-academy#122
I created the new rails migrations to reflect the database changes needed for the multi-category feature see mitre-cyber-academy#122
@rbclark bump |
I'm not really sure the vision is clear here, you originally mentioned wanting to add multi tag support but all of your changes are focused around changing the actual backing data. I'd argue that it is more important to figure out what the frontend should look like and then shape the data based on that, not try to design the backend first. Once the frontend look is more figured out the backend redesign should be a lot easier. The backend is probably close enough for now. |
I thought about:
So now we have something looking like ASIS 2014, we can add a client-side javascript filter like filtryfy or any other lib doing the same thing, to allow user to display only challenges they want to see. See this demo. The Multiple categories filter can be like that:
I would already have developed all of that if I was capable of but I'm not a web dev (nor a dev at all) and I never touched MVC. And even before developing I need that some from the team validate the idea. |
I think if we're going to change the design of the scoreboard we might as well just change the design for everyone. I would be fine with just changing the scoreboard over to a design with more information provided up front and getting rid the category columns in favor of showing them above each challenge with tags. |
This feature has been incorporated into the scoreboard, and multiple categories are now supported. Please feel free to contribute a layout if none of the built in ones are similar to what you are looking for. |
Issue type : enhancement
I know this is may be a breaking feature but it would be nice to support multi-category challenge (or tags support).
For example some challenge are 100% crypto, but some others can be:
This involve change in the database but also in the way you display challenge. This won't be possible to display each challenge in only one category but instead a view like that is needed :
ASIS CTF 2017:
![](https://camo.githubusercontent.com/4209bb97476d63269046f63d9f7c2f45dd112bac48c8f5eb944100df82f60b1f/68747470733a2f2f692e7974696d672e636f6d2f76692f6331645537445232424b512f6d617872657364656661756c742e6a7067)
ASIS CTF 2014:
![](https://camo.githubusercontent.com/ee021ff7d7b8cbe365ed853f9e118fc07a222b82522c5db25f27054d20c290b7/687474703a2f2f332e62702e626c6f6773706f742e636f6d2f2d587974497a7955653852732f553349375149504b5444492f4141414141414141414b632f327473795864586d3956302f73313630302f53637265656e73686f742b66726f6d2b323031342d30352d31332b32323a33323a32332e706e67)
The text was updated successfully, but these errors were encountered: