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 Non-Standard delayed_job Columns to the Display #131

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

Conversation

markbeme
Copy link

@markbeme markbeme commented Apr 25, 2023

Adding non-standard column names to the display is important for any gems or site-specific modifications that add columns to delayed_jobs like https://github.com/codez/delayed_cron_job (which adds the cron column).

Interestingly, this also adds created_at and updated_at to the Display, something I personally find valuable.

Ideas for improvement on this contribution:

  1. Add a section header at the top, "Standard Attributes".
  2. Add "Created At" and "Updated At" to the bottom of the Standard Attributes.
  3. Add created_at and updated_at to the excluding call in line 63 of the contributed job.erb.
  4. If there are any non-standard columns to process, add some whitespace and a section header, "Non-Standard Attributes", "Additional Attributes", etc.
  5. Output all of the non-standard dt and dd values.

…isplay. This is important for any gems that add columns to delayed jobs like https://github.com/codez/delayed_cron_job
@markbeme
Copy link
Author

Tagging @codez for their excellent DelayedCronJob.

@markbeme
Copy link
Author

@andyatkinson @ejschmitt @nashby Should I tag someone else who is currently maintaining delayed_job_web to get this PR merged? Would love to eliminate my fork and give this unto the world. Thanks!

@markbeme
Copy link
Author

@thegeorgeous are you able to merge this PR? Thanks!

@AmritD
Copy link

AmritD commented Nov 10, 2023

Would love to see this merged.

<% job.attribute_names.excluding('id', 'priority', 'attempts', 'queue', 'handler', 'last_error', 'run_at', 'locked_at', 'locked_by', 'failed_at').each do |column| %>
<dt><%= column %></dt>
<dd>
<%=h eval("job.#{column}") %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a security risk here someone could exploit with arbitrary code execution within the eval() block? Any safer alternatives to this with the same result?

I do it's scoped to job.attribute_names, but it feels like there's possible a safer alternative here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

One idea (untested), is there externalized configuration (an initializer?) that can be added with the non-standard column names instead or using eval?

Copy link

Choose a reason for hiding this comment

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

This should be equivalent, I think.

Suggested change
<%=h eval("job.#{column}") %>
<%=h job.send(column) %>

@andyatkinson
Copy link
Collaborator

@markbeme @AmritD I don't use this anymore. I intended to merge it, but I raised a security concern here that gave me pause. Can you take a look?
https://github.com/ejschmitt/delayed_job_web/pull/131/files#r1389677619

Comment on lines +64 to +67
<dt><%= column %></dt>
<dd>
<%=h eval("job.#{column}") %>
</dd>
Copy link

Choose a reason for hiding this comment

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

I also saw that if the value is blank for the column, it breaks the layout. So, this should probably be:

Suggested change
<dt><%= column %></dt>
<dd>
<%=h eval("job.#{column}") %>
</dd>
<% column_value = job.send(column) %>
<% if column_value %>
<dt><%= column %></dt>
<dd>
<%=h column_value %>
</dd>
<% end %>

Copy link

Choose a reason for hiding this comment

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

@markbeme Thoughts?

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.

None yet

3 participants