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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/delayed_job_web/application/views/job.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,11 @@
<%=h job.failed_at %>
</dd>
<% end %>
<% 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) %>

</dd>
Comment on lines +64 to +67
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?

<% end %>
</dl>
</li>