Repository navigation
Conversation
When File.new() or File.open() is used without a code block, the file handle stays open until closed explicitly. Leaked file handles can cause issues on some file systems (e.g. NFS) when cleanup logic tries to delete the parent directory. This patch replaces all obvious read-only uses of File.new() or File.open() with File.read().
Replace outdated file writing patterens (e.g. File.new + write + close or File.open{|f| f.write}) with a single File.write() call where possible.
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis pull request updates record-and-playback scripts and libraries to use Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@record-and-playback/core/scripts/archive/archive.rb`:
- Line 305: The string written to archive_norecord_file in the File.write call
is missing a closing parenthesis, causing incorrect output; update the
File.write invocation that uses archive_norecord_file and meeting_id to include
the closing ")" so the message becomes "Archived #{meeting_id} (no recording
marks)". Ensure you modify the call that constructs that exact string to restore
the matching parenthesis.
In
`@record-and-playback/core/scripts/post_events/post_events_analytics_callback.rb`:
- Around line 176-177: Replace the use of JSON.load when re-reading the file
with JSON.parse to match the write/read round-trip; specifically change the
read/parse of data_json_path where data is assigned (currently data =
JSON.load(File.read(data_json_path))) to use
JSON.parse(File.read(data_json_path)) so that the parsed result of
events_data.to_json is produced with the stricter parse API.
In `@record-and-playback/core/scripts/rap-caption-inbox.rb`:
- Around line 117-119: Replace the interpolated JSON string with a proper JSON
encoder: require 'json' if not present, build a Ruby array/hash using
new_caption_info (e.g. [{ "localeName" => new_caption_info["label"], "locale" =>
new_caption_info["lang"] }]) and call JSON.generate (or .to_json) when writing
to caption_json_file inside the File.open block so values are escaped correctly
instead of using file.puts with an interpolated string.
In `@record-and-playback/core/scripts/utils/captions.rb`:
- Line 57: Replace the use of JSON.load with JSON.parse when reading
captions_playback.json: locate the line that assigns captions using
JSON.load(File.read("#{captions_meeting_dir}/captions_playback.json")) and
change it to call JSON.parse on the file contents (keep the captions variable
and captions_meeting_dir usage), ensuring the plain JSON is parsed without Ruby
object deserialization.
In `@record-and-playback/screenshare/scripts/process/screenshare.rb`:
- Line 167: The line creating an unused variable using JSON.load should be
changed to use JSON.parse and drop the unused assignment: replace the call
JSON.load(File.read("#{process_dir}/captions.json")) with a plain
JSON.parse(File.read("#{process_dir}/captions.json")) invocation (or remove the
assignment entirely and just call JSON.parse(...) to validate the file) so the
code uses the safer parser and the unused variable captions is not created.
In `@record-and-playback/screenshare/scripts/publish/screenshare.rb`:
- Line 77: Replace uses of JSON.load when reading captions.json with JSON.parse
to avoid unsafe object deserialization; specifically change the expression that
sets the captions variable (captions =
JSON.load(File.read("#{process_dir}/captions.json"))) to use
JSON.parse(File.read(...)) in the publish screenshare script, and apply the same
replacement in the process screenshare script where captions.json is read so
both instances use JSON.parse instead of JSON.load.
- Around line 40-41: The YAML safe_load call for screenshare_props is failing
because screenshare.yml uses symbol keys (formats entries like :extension);
update the loading so symbols are permitted or keys become strings: either call
YAML.safe_load(File.read(...), permitted_classes: [Symbol]) (or
permitted_symbols appropriately) when assigning screenshare_props (and keep
using format[:extension]), or change the YAML to use string keys and access
format['extension'] where format is referenced; also replace JSON.load(...) with
JSON.parse(...) when reading captions to follow best practice.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: eb4bba54-897b-454c-80c3-83da5c2eede2
📒 Files selected for processing (30)
record-and-playback/core/lib/recordandplayback.rbrecord-and-playback/core/lib/recordandplayback/edl/audio.rbrecord-and-playback/core/lib/recordandplayback/events_archiver.rbrecord-and-playback/core/lib/recordandplayback/generators/audio_processor.rbrecord-and-playback/core/lib/recordandplayback/generators/events.rbrecord-and-playback/core/lib/recordandplayback/generators/presentation.rbrecord-and-playback/core/lib/recordandplayback/generators/video.rbrecord-and-playback/core/lib/recordandplayback/workers/events_worker.rbrecord-and-playback/core/scripts/archive/archive.rbrecord-and-playback/core/scripts/bbb-0.9-beta-recording-updaterecord-and-playback/core/scripts/bbb-0.9-recording-sizerecord-and-playback/core/scripts/bbb-1.1-meeting-tagrecord-and-playback/core/scripts/post_events/post_events.rb.examplerecord-and-playback/core/scripts/post_events/post_events_analytics_callback.rbrecord-and-playback/core/scripts/rap-caption-inbox.rbrecord-and-playback/core/scripts/rap-process-worker.rbrecord-and-playback/core/scripts/sanity/sanity.rbrecord-and-playback/core/scripts/utils/captions.rbrecord-and-playback/core/test/recordandplayback/generators/test_events.rbrecord-and-playback/notes/scripts/process/notes.rbrecord-and-playback/notes/scripts/publish/notes.rbrecord-and-playback/podcast/scripts/process/podcast.rbrecord-and-playback/podcast/scripts/publish/podcast.rbrecord-and-playback/presentation/scripts/caption/presentationrecord-and-playback/presentation/scripts/process/presentation.rbrecord-and-playback/presentation/scripts/publish/presentation.rbrecord-and-playback/screenshare/scripts/process/screenshare.rbrecord-and-playback/screenshare/scripts/publish/screenshare.rbrecord-and-playback/video/scripts/process/video.rbrecord-and-playback/video/scripts/publish/video.rb
| File.open(archive_norecord_file, "w") do |archive_norecord| | ||
| archive_norecord.write("Archived #{meeting_id} (no recording marks") | ||
| end | ||
| File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks") |
There was a problem hiding this comment.
Close the norecord status message parenthesis.
Line 305 writes "Archived #{meeting_id} (no recording marks" (missing )), which can break exact string matching in downstream tooling.
Suggested fix
- File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks")
+ File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks)")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks") | |
| File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks)") |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@record-and-playback/core/scripts/archive/archive.rb` at line 305, The string
written to archive_norecord_file in the File.write call is missing a closing
parenthesis, causing incorrect output; update the File.write invocation that
uses archive_norecord_file and meeting_id to include the closing ")" so the
message becomes "Archived #{meeting_id} (no recording marks)". Ensure you modify
the call that constructs that exact string to restore the matching parenthesis.
| File.open(caption_json_file, 'w') do |file| | ||
| file.puts "[{\"localeName\": \"#{new_caption_info['label']}\", \"locale\": \"#{new_caption_info['lang']}\"}]" | ||
| end |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"
echo "== File exists? =="
ls -l "$FILE"
echo
echo "== Lines 80-160 (context) =="
nl -ba "$FILE" | sed -n '80,160p'
echo
echo "== Search for caption_json_file usage =="
rg -n "caption_json_file" -S "$FILE"
echo
echo "== Search for JSON usage / requires in this file =="
rg -n "\brequire\s+['\"]json['\"]|JSON\." "$FILE" || true
echo
echo "== Find where new_caption_info is built (best-effort) =="
rg -n "new_caption_info" "$FILE"Repository: bigbluebutton/bigbluebutton
Length of output: 285
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"
echo "== Lines 100-140 (context) =="
awk 'NR>=100 && NR<=140 {printf "%d\t%s\n", NR, $0}' "$FILE"
echo
echo "== Search for caption_json_file usage (best-effort) =="
rg -n "caption_json_file" "$FILE" || true
echo
echo "== Search for JSON usage / requires in this file =="
rg -n "\brequire\s+['\"]json['\"]|JSON\." "$FILE" || true
echo
echo "== Search for new_caption_info construction / usage =="
rg -n "new_caption_info" "$FILE" || true
echo
echo "== Extract the exact lines 110-125 =="
awk 'NR>=110 && NR<=125 {printf "%d\t%s\n", NR, $0}' "$FILE"Repository: bigbluebutton/bigbluebutton
Length of output: 4036
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"
echo "== Lines 1-110 =="
awk 'NR>=1 && NR<=110 {printf "%d\t%s\n", NR, $0}' "$FILE"
echo
echo "== Search for 'new_caption_info['label']' usage =="
rg -n "new_caption_info\['label'\]" "$FILE" || true
echo
echo "== Search for any sanitization/escaping of label/lang =="
rg -n "(label.*gsub|gsub.*label|escape|\\bJSON\\.generate\\b|to_json|sanitize|\\brescue\\b)" "$FILE" || true
echo
echo "== Search for building captions_info and label/lang =="
rg -n "captions_info|caption_info|kind.*|label.*|lang.*" "$FILE"Repository: bigbluebutton/bigbluebutton
Length of output: 5918
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"
echo "== Lines 1-110 =="
awk 'NR>=1 && NR<=110 {printf "%d\t%s\n", NR, $0}' "$FILE"
echo
echo "== Search for 'new_caption_info['label']' usage =="
rg -n "new_caption_info\['label'\]" "$FILE" || true
echo
echo "== Search for sanitization/escaping of label/lang =="
rg -n "(gsub.*(label|lang)|\\bescape\\b|to_json|JSON\\.generate|sanitize)" "$FILE" || true
echo
echo "== Search for building captions_info and label/lang =="
rg -n "captions_info|caption_info|kind.*|label.*|lang.*|json_filename|JSON\\.parse" "$FILE"Repository: bigbluebutton/bigbluebutton
Length of output: 6134
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Repo root assumed
echo "== Search for require 'json' across recordandplayback lib =="
rg -n "require\s+['\"]json['\"]" record-and-playback/core/lib record-and-playback/core lib record-and-playback -S || true
echo
echo "== Search for where JSON is required in imported lib/recordandplayback =="
FILE1="record-and-playback/core/lib/recordandplayback.rb"
if [ -f "$FILE1" ]; then
awk 'NR>=1 && NR<=200 {printf "%d\t%s\n", NR, $0}' "$FILE1"
fi
echo
echo "== Search for label generation/constraints for new_caption_info['label'] =="
# Look for "label" and "temp_filename" near caption index creation.
rg -n "temp_filename|captions.json|localeName|localeName|captions.*inbox|rap-caption-inbox" record-and-playback -S || true
echo
echo "== Search for JSON.generate usage across repo (context for style) =="
rg -n "JSON\.generate\(" -S . || trueRepository: bigbluebutton/bigbluebutton
Length of output: 12616
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Search for '*-track.json' producers =="
rg -n "\*\-track\.json|track\.json|temp_filename|record_id.*track|kind.*track" record-and-playback -S
echo
echo "== Search for JSON objects with keys record_id/label/lang/temp_filename/kind =="
rg -n "['\"]record_id['\"]\s*=>\s*|['\"]label['\"]\s*=>\s*|['\"]lang['\"]\s*=>\s*|['\"]temp_filename['\"]\s*=>\s*|['\"]kind['\"]\s*=>" record-and-playback -S
echo
echo "== Search for writes to captions inbox directory =="
rg -n "captions.*inbox|caption.*inbox|inbox.*captions" record-and-playback -SRepository: bigbluebutton/bigbluebutton
Length of output: 50384
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== rap-caption-inbox.rb tail around inotify/glob (160-210) =="
awk 'NR>=150 && NR<=210 {printf "%d\t%s\n", NR, $0}' record-and-playback/core/scripts/rap-caption-inbox.rb
echo
echo "== Find producers of *-track.json in Ruby (excluding minified JS) =="
rg -n --glob='*.rb' --glob='*.yml' --glob='*.yaml' --glob='*.rb.erb' --glob='*.erb' --glob='*.sh' "\*\-track\.json|track\.json" record-and-playback -S
echo
echo "== Find localeName/label construction in core scripts utils =="
rg -n --glob='*.rb' "localeName|localeName.*label|label\s*=>" record-and-playback/core/scripts/utils -S
echo
echo "== Inspect core/scripts/utils/captions.rb around captions_json write =="
awk 'NR>=1 && NR<=140 {printf "%d\t%s\n", NR, $0}' record-and-playback/core/scripts/utils/captions.rb | sed -n '45,110p'Repository: bigbluebutton/bigbluebutton
Length of output: 3761
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/utils/gen_webvtt"
echo "== File exists? =="
ls -l "$FILE"
echo
echo "== Search for localeName assignment/usage =="
rg -n "localeName" "$FILE" -S
echo
echo "== Context around first localeName usage (best-effort) =="
# Print a few surrounding ranges where localeName appears
# (Use sed with line numbers based on rg output, but keep simple: dump likely areas.)
awk 'NR>=280 && NR<=380 {printf "%d\t%s\n", NR, $0}' "$FILE"
echo
echo "== Context around captions.json write (line ~430-470 from earlier search) =="
awk 'NR>=400 && NR<=520 {printf "%d\t%s\n", NR, $0}' "$FILE"Repository: bigbluebutton/bigbluebutton
Length of output: 6274
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Narrow search to likely generators (exclude minified/vendor JS noise)
rg -n --glob='*.rb' --glob='*.py' --glob='*.erb' --glob='*.sh' --glob='*.yml' --glob='*.yaml' --glob='*.json' \
'\*\-track\.json|-\s*track\.json|\-track\.json' record-and-playback/core -S || true
echo
echo "== Search for temp_filename / record_id / label keys in non-minified code =="
rg -n --glob='*.rb' --glob='*.py' --glob='*.erb' --glob='*.sh' --glob='*.yml' --glob='*.yaml' --glob='*.json' \
"temp_filename|record_id|['\"]label['\"]|localeName|captions.*inbox" record-and-playback -S || true
echo
echo "== Search for writing files into captions inbox directory =="
rg -n --glob='*.rb' --glob='*.py' --glob='*.sh' --glob='*.erb' \
"captions.*inbox.*File\.write|captions.*inbox.*File\.open|captions.*inbox.*write|*-track\.json" record-and-playback -S || trueRepository: bigbluebutton/bigbluebutton
Length of output: 4221
Use a JSON encoder when writing captions.json (avoid interpolated JSON string)
new_caption_info['label'] / new_caption_info['lang'] are inserted into a raw JSON string without escaping, so quotes/backslashes/control characters would make the resulting captions.json invalid.
Suggested fix
- File.open(caption_json_file, 'w') do |file|
- file.puts "[{\"localeName\": \"#{new_caption_info['label']}\", \"locale\": \"#{new_caption_info['lang']}\"}]"
- end
+ caption_payload = [{
+ localeName: new_caption_info['label'],
+ locale: new_caption_info['lang']
+ }]
+ File.write(caption_json_file, JSON.generate(caption_payload))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| File.open(caption_json_file, 'w') do |file| | |
| file.puts "[{\"localeName\": \"#{new_caption_info['label']}\", \"locale\": \"#{new_caption_info['lang']}\"}]" | |
| end | |
| caption_payload = [{ | |
| localeName: new_caption_info['label'], | |
| locale: new_caption_info['lang'] | |
| }] | |
| File.write(caption_json_file, JSON.generate(caption_payload)) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@record-and-playback/core/scripts/rap-caption-inbox.rb` around lines 117 -
119, Replace the interpolated JSON string with a proper JSON encoder: require
'json' if not present, build a Ruby array/hash using new_caption_info (e.g. [{
"localeName" => new_caption_info["label"], "locale" => new_caption_info["lang"]
}]) and call JSON.generate (or .to_json) when writing to caption_json_file
inside the File.open block so values are escaped correctly instead of using
file.puts with an interpolated string.
8f69dea to
14c2f40
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
record-and-playback/screenshare/scripts/publish/screenshare.rb (1)
40-41:⚠️ Potential issue | 🔴 Critical | ⚡ Quick win
screenshare.ymlloading is now incompatible withformat[:extension]accessLine 40-41 switched to
YAML::safe_load, but this path still expects symbol-keyedformatsentries (format[:extension]on Line 72). That can fail during load (Psych::DisallowedClass) or break key lookup, causing publish-time copy failures.Proposed minimal fix
-props = YAML::safe_load(File.read(File.expand_path('../../bigbluebutton.yml', __FILE__))) -screenshare_props = YAML::safe_load(File.read(File.expand_path('../../screenshare.yml', __FILE__))) +props = YAML.safe_load(File.read(File.expand_path('../../bigbluebutton.yml', __FILE__))) +screenshare_props = YAML.safe_load( + File.read(File.expand_path('../../screenshare.yml', __FILE__)), + permitted_classes: [Symbol] +)#!/bin/bash set -euo pipefail YML="record-and-playback/screenshare/scripts/screenshare.yml" echo "== Verify default safe_load behavior ==" ruby -ryaml -e ' content = File.read(ARGV[0]) begin y = YAML.safe_load(content) f0 = y["formats"]&.first puts "safe_load succeeded" puts "first format keys: #{f0&.keys.inspect}" puts "format[:extension] => #{f0&.[](:extension).inspect}" rescue => e puts "#{e.class}: #{e.message}" exit 2 end ' "$YML" echo "== Verify with Symbol permitted ==" ruby -ryaml -e ' content = File.read(ARGV[0]) y = YAML.safe_load(content, permitted_classes: [Symbol]) f0 = y["formats"].first puts "first format keys: #{f0.keys.inspect}" puts "format[:extension] => #{f0[:extension].inspect}" ' "$YML"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@record-and-playback/screenshare/scripts/publish/screenshare.rb` around lines 40 - 41, The YAML loading of screenshare_props uses YAML::safe_load which by default yields string keys and disallows Symbol objects, breaking later symbol-key access like format[:extension]; update the load call for screenshare_props to call YAML::safe_load with options to restore symbol-key behavior (e.g., permitted_classes: [Symbol] and symbolize_names: true) so that later code referencing format[:extension] and other symbol keys continues to work, keeping the variable name screenshare_props and the same callers intact.
🧹 Nitpick comments (1)
record-and-playback/podcast/scripts/process/podcast.rb (1)
42-42: ⚡ Quick winRemove unused
podcast_propsload at Line 42 (or wire it into behavior).Right now it adds an unnecessary parse/read path with no effect.
Proposed fix
-podcast_props = YAML::safe_load(File.read('podcast.yml'))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@record-and-playback/podcast/scripts/process/podcast.rb` at line 42, The variable podcast_props is assigned from YAML::safe_load(File.read('podcast.yml')) but never used; either remove that line or wire podcast_props into relevant behavior (e.g., pass it into the method that builds podcast metadata or replace hardcoded values with podcast_props). Locate the assignment to podcast_props in podcast.rb (the YAML::safe_load/File.read call) and either delete it or update the surrounding code to consume podcast_props where podcast metadata/config is needed (e.g., use podcast_props instead of hardcoded config or pass it into the processing function).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@record-and-playback/screenshare/scripts/publish/screenshare.rb`:
- Around line 40-41: The YAML loading of screenshare_props uses YAML::safe_load
which by default yields string keys and disallows Symbol objects, breaking later
symbol-key access like format[:extension]; update the load call for
screenshare_props to call YAML::safe_load with options to restore symbol-key
behavior (e.g., permitted_classes: [Symbol] and symbolize_names: true) so that
later code referencing format[:extension] and other symbol keys continues to
work, keeping the variable name screenshare_props and the same callers intact.
---
Nitpick comments:
In `@record-and-playback/podcast/scripts/process/podcast.rb`:
- Line 42: The variable podcast_props is assigned from
YAML::safe_load(File.read('podcast.yml')) but never used; either remove that
line or wire podcast_props into relevant behavior (e.g., pass it into the method
that builds podcast metadata or replace hardcoded values with podcast_props).
Locate the assignment to podcast_props in podcast.rb (the
YAML::safe_load/File.read call) and either delete it or update the surrounding
code to consume podcast_props where podcast metadata/config is needed (e.g., use
podcast_props instead of hardcoded config or pass it into the processing
function).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f6fce3fc-b65b-45b4-ab58-c6131aa1816a
📒 Files selected for processing (17)
record-and-playback/core/lib/recordandplayback.rbrecord-and-playback/core/lib/recordandplayback/events_archiver.rbrecord-and-playback/core/scripts/bbb-0.9-beta-recording-updaterecord-and-playback/core/scripts/bbb-0.9-recording-sizerecord-and-playback/core/scripts/bbb-1.1-meeting-tagrecord-and-playback/core/scripts/post_events/post_events_analytics_callback.rbrecord-and-playback/core/scripts/rap-process-worker.rbrecord-and-playback/core/scripts/utils/captions.rbrecord-and-playback/notes/scripts/process/notes.rbrecord-and-playback/notes/scripts/publish/notes.rbrecord-and-playback/podcast/scripts/process/podcast.rbrecord-and-playback/podcast/scripts/publish/podcast.rbrecord-and-playback/presentation/scripts/caption/presentationrecord-and-playback/presentation/scripts/process/presentation.rbrecord-and-playback/presentation/scripts/publish/presentation.rbrecord-and-playback/screenshare/scripts/process/screenshare.rbrecord-and-playback/screenshare/scripts/publish/screenshare.rb
This is not necessary for security because we only load trusted config files, but linters and AI tools tend to complain about the 'insecure' use of YAML::load or JSON.load. json
14c2f40 to
baaea29
Compare
|
germanocaumo
left a comment
There was a problem hiding this comment.
This is breaking screenshare format: screenshare.yml currently uses YAML symbols, so plain YAML.safe_load breaks with Psych::DisallowedClass, and publish/screenshare.rb also mixes string/symbol key access.
We can use permitted_classes: [Symbol] so it can work
Maybe we should document the supported YAML features for recording config/override files now that it will use safe_load.
For example, clarify whether admin overrides may use symbols, anchors/aliases, dates, etc. Symbols are already needed by legacy screenshare.yml
Also, there are a few files with some trailing/EOF whitespace, please fix
|
Wow, ruby YAML loading is a mess. Anchors/aliases are a core YAML feature and should be supported. Not sure about symbols (Ruby special case) or dates (not used anywhere AFAIK). To be backwards compatible we would need to use Should I do that, or better revert the |
|
This pull request has conflicts ☹ |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb (1)
299-305: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor inconsistency: this block still uses
File.open/block-write instead ofFile.write.Elsewhere in this same PR (e.g. line 405) the equivalent pattern was converted to
File.write. For consistency, this could build the ffconcat content as a string first and useFile.write.♻️ Optional consistency refactor
- File.open(concat_list_file, 'w') do |f| - f.write("ffconcat version 1.0\n") - segment_files.each do |segment| - f.write("file #{segment[:file]}\n") - end - end + concat_list_content = "ffconcat version 1.0\n" + + segment_files.map { |segment| "file #{segment[:file]}\n" }.join + File.write(concat_list_file, concat_list_content)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb` around lines 299 - 305, The ffconcat list creation in the audio EDL flow still uses File.open with incremental writes, while the same pattern elsewhere was switched to File.write. Update the concat list generation in the same area that builds concat_list_file and iterates segment_files to assemble the full ffconcat content string first, then write it once with File.write for consistency with the newer pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 238-266: The ffmpeg extraction failure path in the audio remux
loop is silently dropping the source because `corrupt_audios` is updated before
`BigBlueButton.exec_ret`, but there is no warning when `exitstatus != 0`. In the
`audio_video_files.each` block, add a `BigBlueButton.logger.warn` for the failed
extract_cmd case and only mark the file as corrupt after a failed extraction is
handled consistently with the other corruption checks. Use the existing
`audio_video_files.each`, `extract_cmd`, `exitstatus`, and `corrupt_audios` flow
to locate and update the logic.
---
Nitpick comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 299-305: The ffconcat list creation in the audio EDL flow still
uses File.open with incremental writes, while the same pattern elsewhere was
switched to File.write. Update the concat list generation in the same area that
builds concat_list_file and iterates segment_files to assemble the full ffconcat
content string first, then write it once with File.write for consistency with
the newer pattern.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 596645ca-1592-4f1f-a866-f75d738e2c43
📒 Files selected for processing (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🧹 Nitpick comments (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb (1)
299-305: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor inconsistency: this block still uses
File.open/block-write instead ofFile.write.Elsewhere in this same PR (e.g. line 405) the equivalent pattern was converted to
File.write. For consistency, this could build the ffconcat content as a string first and useFile.write.♻️ Optional consistency refactor
- File.open(concat_list_file, 'w') do |f| - f.write("ffconcat version 1.0\n") - segment_files.each do |segment| - f.write("file #{segment[:file]}\n") - end - end + concat_list_content = "ffconcat version 1.0\n" + + segment_files.map { |segment| "file #{segment[:file]}\n" }.join + File.write(concat_list_file, concat_list_content)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb` around lines 299 - 305, The ffconcat list creation in the audio EDL flow still uses File.open with incremental writes, while the same pattern elsewhere was switched to File.write. Update the concat list generation in the same area that builds concat_list_file and iterates segment_files to assemble the full ffconcat content string first, then write it once with File.write for consistency with the newer pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 238-266: The ffmpeg extraction failure path in the audio remux
loop is silently dropping the source because `corrupt_audios` is updated before
`BigBlueButton.exec_ret`, but there is no warning when `exitstatus != 0`. In the
`audio_video_files.each` block, add a `BigBlueButton.logger.warn` for the failed
extract_cmd case and only mark the file as corrupt after a failed extraction is
handled consistently with the other corruption checks. Use the existing
`audio_video_files.each`, `extract_cmd`, `exitstatus`, and `corrupt_audios` flow
to locate and update the logic.
---
Nitpick comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 299-305: The ffconcat list creation in the audio EDL flow still
uses File.open with incremental writes, while the same pattern elsewhere was
switched to File.write. Update the concat list generation in the same area that
builds concat_list_file and iterates segment_files to assemble the full ffconcat
content string first, then write it once with File.write for consistency with
the newer pattern.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 596645ca-1592-4f1f-a866-f75d738e2c43
📒 Files selected for processing (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb
🛑 Comments failed to post (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb (1)
238-266: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Silent audio drop on ffmpeg extraction failure — missing warning log.
filenameis added tocorrupt_audiosbefore the extract command runs (line 242), so ifexec_retfails (line 246), the audio+video source is dropped from the output entirely with no log message — unlike the sibling corruption paths at lines 224-227 and 250-252, which both warn. This makes lost audio hard to diagnose in production.🩹 Proposed fix
exitstatus = BigBlueButton.exec_ret(*extract_cmd) - next if exitstatus != 0 + if exitstatus != 0 + BigBlueButton.logger.warn(" Failed to extract audio from #{filename}, exit code #{exitstatus}. It will be removed from the output.") + next + end📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.audio_video_files.each do |filename, info| next if corrupt_audios.include?(filename) BigBlueButton.logger.info("Extracting audio from #{filename}") corrupt_audios << filename out_filename = "#{process_dir}/#{File.basename(filename, '.*')}-audio.mkv" extract_cmd = [*FFMPEG, '-copyts', '-i', filename, '-map', '0:a:0', '-c', 'copy', '-f', 'matroska', out_filename] exitstatus = BigBlueButton.exec_ret(*extract_cmd) if exitstatus != 0 BigBlueButton.logger.warn(" Failed to extract audio from #{filename}, exit code #{exitstatus}. It will be removed from the output.") next end new_info = audio_info(out_filename) new_info[:original_duration] = info[:original_duration] if info.include?(:original_duration) if !new_info[:audio] || !new_info[:duration] BigBlueButton.logger.warn(' This audio file is corrupt! It will be removed from the output.') next else BigBlueButton.logger.debug(" format: #{new_info[:format][:format_name]}, codec: #{new_info[:audio][:codec_name]}") BigBlueButton.logger.debug(" sample rate: #{new_info[:sample_rate]}, duration: #{new_info[:duration]}") audioinfo[out_filename] = new_info end # Update all the EDL entries to point at the new remuxed file edl.each do |event| audio = event[:audios]&.find { |a| a[:filename] == filename } next unless audio audio[:filename] = out_filename end end🧰 Tools
🪛 RuboCop (1.88.0)
[convention] 254-254: Line is too long. [129/128]
(Layout/LineLength)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb` around lines 238 - 266, The ffmpeg extraction failure path in the audio remux loop is silently dropping the source because `corrupt_audios` is updated before `BigBlueButton.exec_ret`, but there is no warning when `exitstatus != 0`. In the `audio_video_files.each` block, add a `BigBlueButton.logger.warn` for the failed extract_cmd case and only mark the file as corrupt after a failed extraction is handled consistently with the other corruption checks. Use the existing `audio_video_files.each`, `extract_cmd`, `exitstatus`, and `corrupt_audios` flow to locate and update the logic.
✅ Automated tests have passed! |
@defnull I would recommend: require 'date'
require 'yaml'
module BigBlueButton
YAML_PERMITTED_CLASSES = [Symbol, Date, Time].freeze
def self.load_yaml(path, fallback: {})
YAML.safe_load_file(path, permitted_classes: YAML_PERMITTED_CLASSES, aliases: true) || fallback
end
endadd date and time to also be defensive to other types that could be in the override file then replacing all safe_load call sites to the helper |
|
Closed via #25952 in BBB 4.0. Thank you! |


What does this PR do?
This PR refactors multiple recording scripts and replaces some outdated file handling patterns with more modern (and more clean) alternatives. It also replaces all
YAML::loadcalls withYAML::safe_loadto avoid code checker warnings. This is not necessary for security though, as we only load trusted files.Motivation
The recording scripts really need some work and we have to start somewhere.
Notes