Skip to content

code cleanup#192

Merged
corrodis merged 9 commits intodevelopfrom
sc/codeCleanUp
Mar 6, 2026
Merged

code cleanup#192
corrodis merged 9 commits intodevelopfrom
sc/codeCleanUp

Conversation

@corrodis
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the get_artdaq_log_filenames method to improve command execution security and output parsing reliability. The changes modernize subprocess usage by replacing Popen with subprocess.run, eliminate shell injection vulnerabilities through proper command quoting, and introduce structured output parsing.

Changes:

  • Modernized subprocess execution from Popen with shell=True to subprocess.run with explicit argument lists
  • Improved SSH command security by using shlex.quote() to prevent command injection
  • Simplified output parsing by replacing natural language format with structured markers (__DAQLOG__N__)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"echo Logfile for process %s on %s is $filename_%s"
% (procinfo.label, procinfo.host, i_p)
)
cmds.append("echo __DAQLOG__%s__ $filename_%s" % (i_p, i_p))
Copy link
Contributor

Choose a reason for hiding this comment

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

This message appears to be much less informative...is there a reason for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this is used for parsing to then match the correct logfile (that led to issues before). The key is to map the logfile to the i_p, this is what this is used for. The label and host are already known by artdaq-daqinterface. I added a log entry that combines all this (but not here).

Copy link
Contributor

Choose a reason for hiding this comment

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

@eflumerf are you happy with this?

Copy link
Contributor

Copilot AI commented Feb 27, 2026

@eflumerf I've opened a new pull request, #193, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 27, 2026 19:51
Co-authored-by: eflumerf <61473357+eflumerf@users.noreply.github.com>
Use enumerate loop variable directly instead of re-indexing list
Copy link
Contributor

@rrivera747 rrivera747 left a comment

Choose a reason for hiding this comment

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

@corrodis can you please resolve the copilot suggestions (it's fine to mark 'thumbs down' or 'ignore' and then click resolve). Thanks!

@corrodis corrodis requested a review from eflumerf March 5, 2026 04:07
@corrodis
Copy link
Contributor Author

corrodis commented Mar 5, 2026

@rrivera747 all done and tested

@rrivera747 rrivera747 self-requested a review March 6, 2026 15:20
Copy link
Contributor

@rrivera747 rrivera747 left a comment

Choose a reason for hiding this comment

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

Looks good to me - thanks!

@corrodis corrodis merged commit 86150d2 into develop Mar 6, 2026
10 checks passed
@corrodis corrodis deleted the sc/codeCleanUp branch March 6, 2026 21:38
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.

5 participants