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

Mappings manager/migrate templates to db #1248

Conversation

etdsoft
Copy link
Member

@etdsoft etdsoft commented Mar 28, 2024

Summary

This is a restore of the now closed #1232

app/services/mapping_migration_service.rb Outdated Show resolved Hide resolved
app/services/mapping_migration_service.rb Outdated Show resolved Hide resolved
app/services/mapping_migration_service.rb Outdated Show resolved Hide resolved
app/services/mapping_migration_service.rb Outdated Show resolved Hide resolved
)
end

def create_mapping_fields(mapping, template_file)
Copy link
Member Author

Choose a reason for hiding this comment

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

A lot of this, including regexp parsing and #update_syntax method seem to be separate concerns that should be encapsulated elsewhere?

The logic seems to replicate what we already have in

https://github.com/dradis/dradis-ce/blob/develop/app/models/field_parser.rb

and

https://github.com/dradis/dradis-plugins/blob/main/lib/dradis/plugins/templates.rb

If this class's responsibility is to turn .template fields into DB records, it seems that some other class/module/concern's should be understanding the actual content. Manipulating text seems a bit out of scope? Perhaps not it's just clarity and naming conventions.

@integration_name = integration.plugin_name.to_s
set_integration_template_dirs

if integration.uploaders.count > 1
Copy link
Member Author

Choose a reason for hiding this comment

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

We do we need to keep two separate code paths?

Isn't a single-uploader integration a particular case of a multiple-uploader integration, where the count is 1 (or collection has a single element)? That was the spirit of the architecture between multiple uploaders.

Copy link
Contributor

Choose a reason for hiding this comment

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

The only reason for this check here is that for our integrations with multiple uploaders we renamed their templates since they were not following a convention. Since we renamed them, the Mapping source isn't going to match the name of the .template file so we had to handle these cases differently

db/migrate/20240226193757_migrate_templates_to_mappings.rb Outdated Show resolved Hide resolved
config/initializers/z_11_plugin_templates.rb Outdated Show resolved Hide resolved
@caitmich caitmich merged commit 64e7b52 into mappings-manager/add-uploaders Apr 9, 2024
@caitmich caitmich deleted the mappings-manager/migrate-templates-to-db branch April 9, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants