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

Add LiquidAssignsService #1205

Merged
merged 13 commits into from
Dec 1, 2023
Merged

Add LiquidAssignsService #1205

merged 13 commits into from
Dec 1, 2023

Conversation

aapomm
Copy link
Contributor

@aapomm aapomm commented Nov 21, 2023

Spec

Right now, we're creating liquid_assigns in a controller concern, and when we need liquid_assigns outside of a controller, we're manually creating the hash.

Proposed solution
Implement a LiquidAssignsService class to build a hash for liquid_assigns based on the given project.

Other Information

If there's anything else that's important and relevant to your pull
request, mention that information here. This could include
benchmarks, or other information.

Thanks for contributing to Dradis!

Copyright assignment

Collaboration is difficult with commercial closed source but we want
to keep as much of the OSS ethos as possible available to users
who want to fix it themselves.

In order to unambiguously own and sell Dradis Framework commercial
products, we must have the copyright associated with the entire
codebase. Any code you create which is merged must be owned by us.
That's not us trying to be a jerks, that's just the way it works.

Please review the CONTRIBUTING.md
file for the details.

You can delete this section, but the following sentence needs to
remain in the PR's description:

I assign all rights, including copyright, to any future Dradis
work by myself to Security Roots.

Check List

  • Added a CHANGELOG entry

result['evidences'] = project.evidence.map { |evidence| EvidenceDrop.new(evidence) }
result['tags'] = project.tags.map { |tag| TagDrop.new(tag) }

if defined?(Dradis::Pro)
Copy link
Contributor

@caitmich caitmich Nov 22, 2023

Choose a reason for hiding this comment

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

What about passing in kwargs instead?
Ex.
@team = args.fetch(:team, nil) in the initializer, and
result['team'] = TeamDrop.new(project.team) if team
on L19
to remove the need for the Dradis::Pro check

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 like that better than the Dradis::Pro check but listing all the args sort of defeats the convenience this brings for the caller. If a caller has to instantiate the class with the following:

LiquidAssignsService.new(
  project: project,
  team: project.team,
  document_properties: project.content_library.properties
)

Then it starts to look like:

result['project'] = ...
result['document_properties'] = ...
result['team'] = ...

just without the drop?

Copy link
Member

Choose a reason for hiding this comment

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

I'd extract this to a #assigns_pro that only gets called if defined? as we do in other places.

@caitmich caitmich changed the base branch from add-global-drops to develop November 22, 2023 21:13
@@ -61,6 +61,11 @@

expect do
visit project_trash_path(current_project)

within '#trash' do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bit unrelated to the task but it makes this specific spec not dependent on the other specs that create records by counting the records in the trash instead of expecting it to be empty.

@caitmich caitmich merged commit 9a10384 into develop Dec 1, 2023
@caitmich caitmich deleted the liquid-assigns-service branch December 1, 2023 19:15
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.

3 participants