Skip to content

fix(recording): Avoid leaking file handles in ruby scripts. - #25123

Closed
defnull wants to merge 1 commit into
bigbluebutton:v3.0.x-developfrom
defnull:defnull-leaked-files
Closed

defnull wants to merge 1 commit into
bigbluebutton:v3.0.x-developfrom
defnull:defnull-leaked-files

Conversation

@defnull

@defnull defnull commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Second attempt at fixing recording processing on NFS file systems.

See #9857 and for an #10984 for context.

Work in progress and untested!

What does this PR do?

When 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.open() with File.read().

Closes Issue(s)

Replaces #24772

@coderabbitai

coderabbitai Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This pull request changes file reading across the record-and-playback area to use File.read(...) (in-memory strings) instead of passing File.open(...) IO handles into YAML.safe_load/YAML.load, Nokogiri::XML, JSON.load/JSON.parse. Edits touch core libraries, generators, workers, scripts for notes/podcast/presentation/screenshare/video, utilities, and tests; no parsing logic or downstream behavior was altered.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation (NFS file system issues), the problem (leaked file handles from File.open()), and the solution (replacing with File.read()).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The PR title accurately describes the main change: replacing File.open() with File.read() across multiple recording scripts to avoid leaking file handles. All file summaries confirm this is the primary modification throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
record-and-playback/podcast/scripts/publish/podcast.rb (1)

126-130: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing NFS-safe cleanup change called out in the linked issue.

Same gap as in notes/scripts/publish/notes.rb: per issue #24772, these FileUtils.rm_r(<dir>) calls are the ones that hit Errno::ENOTEMPTY on NFSv4. The recommended pattern (matching presentation.rb) is to remove directory contents via Dir.glob rather than the directory itself. The File.read change alone won't close out the issue this PR claims to fix.

🛠️ Proposed fix
       BigBlueButton.logger.info("Removing processed files.")
-      FileUtils.rm_r(process_dir)
+      FileUtils.rm_r(Dir.glob("#{process_dir}/*"))

       BigBlueButton.logger.info("Removing published files.")
-      FileUtils.rm_r(target_dir)
+      FileUtils.rm_r(Dir.glob("#{target_dir}/*"))
🤖 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/publish/podcast.rb` around lines 126 -
130, Replace the unsafe FileUtils.rm_r calls that remove the directories
themselves with an NFS-safe pattern that removes only their contents: change the
two occurrences of FileUtils.rm_r(process_dir) and FileUtils.rm_r(target_dir) so
they iterate over Dir.glob of each directory's entries (including dotfiles),
skip “.” and “..”, and remove each entry (e.g., with FileUtils.rm_rf) instead;
keep the existing BigBlueButton.logger.info messages around the operations and
apply the same pattern used in presentation.rb to avoid Errno::ENOTEMPTY on
NFSv4.
record-and-playback/notes/scripts/publish/notes.rb (1)

131-135: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing NFS-safe cleanup change called out in the linked issue.

Per the linked issue #24772, the cleanup here is exactly the spot that fails on NFSv4 with Errno::ENOTEMPTY because rmdir runs before client-cache deletions are flushed. The recommended fix — already used by presentation.rb — is to delete the directory contents via a glob rather than the directory itself. The File.read swap alone doesn't address this; the rm_r calls below still target the parent dir.

🛠️ Proposed fix
       BigBlueButton.logger.info("Removing processed files.")
-      FileUtils.rm_r(process_dir)
+      FileUtils.rm_r(Dir.glob("#{process_dir}/*"))

       BigBlueButton.logger.info("Removing published files.")
-      FileUtils.rm_r(target_dir)
+      FileUtils.rm_r(Dir.glob("#{target_dir}/*"))
🤖 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/notes/scripts/publish/notes.rb` around lines 131 - 135,
The cleanup uses FileUtils.rm_r on process_dir and target_dir which fails on
NFSv4 (Errno::ENOTEMPTY); change the removal to delete directory contents via
glob (e.g., Dir.glob(File.join(process_dir, '*'), File::FNM_DOTMATCH) and same
for target_dir) and remove items individually rather than calling FileUtils.rm_r
on the parent dir; update the logic in the block that logs via
BigBlueButton.logger.info so it mirrors the NFS-safe approach used in
presentation.rb and handles files/dirs and hidden entries correctly.
record-and-playback/core/scripts/bbb-1.1-meeting-tag (1)

43-43: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remaining file-handle leak in the same script.

The block here is Nokogiri's parse-options block (|x| x.noblanks), not File.open's block, so the file handle returned by File.open(xml_filename) is never explicitly closed — the same leak pattern this PR is fixing elsewhere. Consider switching to File.read for consistency with the rest of the cleanup.

Proposed fix
-  doc = Nokogiri::XML(File.open(xml_filename)) { |x| x.noblanks }
+  doc = Nokogiri::XML(File.read(xml_filename)) { |x| x.noblanks }
🤖 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/bbb-1.1-meeting-tag` at line 43, The
Nokogiri::XML call uses File.open(xml_filename) without closing the handle (the
block {|x| x.noblanks } is Nokogiri's, not File.open's), causing a file-handle
leak; replace File.open(xml_filename) with File.read(xml_filename) so
Nokogiri::XML receives the file content string (keep the parse-options block |x|
x.noblanks) and remove any lingering File.open usage around the doc variable to
match the other fixes.
🤖 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/presentation/scripts/caption/presentation`:
- Line 49: Replace the insecure YAML::load call used to populate
presOverrideProps from filepathPresOverride with YAML.safe_load, mirroring the
same options (permitted_classes/permitted_symbols/aliases) used elsewhere in the
file (lines that already call YAML.safe_load) so the parsed data remains
compatible; specifically change the presOverrideProps =
YAML::load(File.read(filepathPresOverride)) invocation to use
YAML.safe_load(File.read(filepathPresOverride), ...) with the same safe options
as the other safe_load usages.

In `@record-and-playback/presentation/scripts/process/presentation.rb`:
- Line 47: The code uses YAML::load when reading filepathPresOverride into
presOverrideProps which is unsafe; replace the YAML::load call with
YAML.safe_load and match the same safe_load options used elsewhere in the file
(use the same permitted classes/aliases/whitelist settings as the earlier
safe_load usage) so presOverrideProps =
YAML.safe_load(File.read(filepathPresOverride), ...) and remove the unsafe
YAML::load usage.

In `@record-and-playback/presentation/scripts/publish/presentation.rb`:
- Line 42: Replace the unsafe YAML::load call that sets presOverrideProps with
YAML.safe_load using the same options as the base config safe_load call: read
the file via File.read(filepathPresOverride) and pass it to YAML.safe_load with
the same permitted_classes/permitted_symbols and aliases settings used for the
earlier base config, e.g. presOverrideProps =
YAML.safe_load(File.read(filepathPresOverride), permitted_classes: ...,
permitted_symbols: ..., aliases: ...), so loading matches the secure pattern.

In `@record-and-playback/screenshare/scripts/process/screenshare.rb`:
- Around line 43-44: The two lines that assign props and screenshare_props use
YAML::load and must be changed to YAML.safe_load to avoid arbitrary code
execution; update the assignments for props and screenshare_props (the YAML file
reads that call File.read(File.expand_path(...))) to call YAML.safe_load
instead, and pass any required options (e.g., permitted_classes,
permitted_symbols or aliases: true) appropriate for your YAML content so parsing
still succeeds while preventing unsafe deserialization.

In `@record-and-playback/screenshare/scripts/publish/screenshare.rb`:
- Around line 40-41: The YAML loading uses unsafe YAML::load for props and
screenshare_props which can execute arbitrary code; change both calls that
create props and screenshare_props to use YAML.safe_load, passing the file
contents and (optionally) permitted classes or permitted symbols as needed
(e.g., YAML.safe_load(File.read(...), permitted_classes: [], permitted_symbols:
[])) so deserialization is restricted and secure while preserving the same
variables (props, screenshare_props).

---

Outside diff comments:
In `@record-and-playback/core/scripts/bbb-1.1-meeting-tag`:
- Line 43: The Nokogiri::XML call uses File.open(xml_filename) without closing
the handle (the block {|x| x.noblanks } is Nokogiri's, not File.open's), causing
a file-handle leak; replace File.open(xml_filename) with File.read(xml_filename)
so Nokogiri::XML receives the file content string (keep the parse-options block
|x| x.noblanks) and remove any lingering File.open usage around the doc variable
to match the other fixes.

In `@record-and-playback/notes/scripts/publish/notes.rb`:
- Around line 131-135: The cleanup uses FileUtils.rm_r on process_dir and
target_dir which fails on NFSv4 (Errno::ENOTEMPTY); change the removal to delete
directory contents via glob (e.g., Dir.glob(File.join(process_dir, '*'),
File::FNM_DOTMATCH) and same for target_dir) and remove items individually
rather than calling FileUtils.rm_r on the parent dir; update the logic in the
block that logs via BigBlueButton.logger.info so it mirrors the NFS-safe
approach used in presentation.rb and handles files/dirs and hidden entries
correctly.

In `@record-and-playback/podcast/scripts/publish/podcast.rb`:
- Around line 126-130: Replace the unsafe FileUtils.rm_r calls that remove the
directories themselves with an NFS-safe pattern that removes only their
contents: change the two occurrences of FileUtils.rm_r(process_dir) and
FileUtils.rm_r(target_dir) so they iterate over Dir.glob of each directory's
entries (including dotfiles), skip “.” and “..”, and remove each entry (e.g.,
with FileUtils.rm_rf) instead; keep the existing BigBlueButton.logger.info
messages around the operations and apply the same pattern used in
presentation.rb to avoid Errno::ENOTEMPTY on NFSv4.
🪄 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: 9555218a-2218-459c-9eef-fd52b03e647d

📥 Commits

Reviewing files that changed from the base of the PR and between 4d779ef and 902e4d8.

📒 Files selected for processing (29)
  • record-and-playback/core/lib/recordandplayback.rb
  • record-and-playback/core/lib/recordandplayback/events_archiver.rb
  • record-and-playback/core/lib/recordandplayback/generators/audio_processor.rb
  • record-and-playback/core/lib/recordandplayback/generators/events.rb
  • record-and-playback/core/lib/recordandplayback/generators/presentation.rb
  • record-and-playback/core/lib/recordandplayback/generators/video.rb
  • record-and-playback/core/lib/recordandplayback/workers/events_worker.rb
  • record-and-playback/core/scripts/archive/archive.rb
  • record-and-playback/core/scripts/bbb-0.9-beta-recording-update
  • record-and-playback/core/scripts/bbb-0.9-recording-size
  • record-and-playback/core/scripts/bbb-1.1-meeting-tag
  • record-and-playback/core/scripts/post_events/post_events.rb.example
  • record-and-playback/core/scripts/post_events/post_events_analytics_callback.rb
  • record-and-playback/core/scripts/rap-caption-inbox.rb
  • record-and-playback/core/scripts/rap-process-worker.rb
  • record-and-playback/core/scripts/sanity/sanity.rb
  • record-and-playback/core/scripts/utils/captions.rb
  • record-and-playback/core/test/recordandplayback/generators/test_events.rb
  • record-and-playback/notes/scripts/process/notes.rb
  • record-and-playback/notes/scripts/publish/notes.rb
  • record-and-playback/podcast/scripts/process/podcast.rb
  • record-and-playback/podcast/scripts/publish/podcast.rb
  • record-and-playback/presentation/scripts/caption/presentation
  • record-and-playback/presentation/scripts/process/presentation.rb
  • record-and-playback/presentation/scripts/publish/presentation.rb
  • record-and-playback/screenshare/scripts/process/screenshare.rb
  • record-and-playback/screenshare/scripts/publish/screenshare.rb
  • record-and-playback/video/scripts/process/video.rb
  • record-and-playback/video/scripts/publish/video.rb

@antobinary antobinary added this to the Release 3.0 milestone May 21, 2026
@antobinary antobinary changed the title [WIP] fix: Avoid leaking file handles in ruby scripts. [WIP] fix(recording): Avoid leaking file handles in ruby scripts. May 21, 2026
@antobinary

Copy link
Copy Markdown
Member

We appreciate these changes!! Thanks!

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().
@defnull
defnull force-pushed the defnull-leaked-files branch from 902e4d8 to 078c047 Compare May 21, 2026 23:18
@defnull

defnull commented May 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Found more places and force-pushed. I'll ignore the YAML::safe_load remarks for now (we only load trusted config files) and open a separate PR for that.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
13.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 8

♻️ Duplicate comments (1)
record-and-playback/screenshare/scripts/publish/screenshare.rb (1)

40-41: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Replace YAML::load with YAML.safe_load for security.

Using YAML::load can execute arbitrary Ruby code embedded in YAML files. Replace with YAML.safe_load to prevent deserialization attacks.

🔒 Proposed fix
-props = YAML::load(File.read(File.expand_path('../../bigbluebutton.yml', __FILE__)))
-screenshare_props = YAML::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__)))
🤖 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 calls using YAML::load for variables props and
screenshare_props are unsafe; replace them with YAML.safe_load, passing the file
contents and a permitted classes/aliases list or set permitted_classes: [],
aliases: true/false as needed to avoid executing arbitrary Ruby objects; update
the two occurrences (the expressions creating props and screenshare_props) to
call YAML.safe_load(File.read(...), permitted_classes: [], aliases: false) or an
appropriate safe configuration for the expected YAML content.
🧹 Nitpick comments (3)
record-and-playback/core/lib/recordandplayback.rb (1)

247-249: ⚖️ Poor tradeoff

Consider YAML.safe_load for improved security.

The code uses YAML.load, which can instantiate arbitrary Ruby objects and potentially execute code. While this PR correctly switches from File.open to File.read to prevent file handle leaks, consider also migrating to YAML.safe_load with an allowlist of permitted classes for defense-in-depth, especially since these configuration files control recording behavior.

Note: This is a pre-existing security posture issue, not introduced by this PR.

🤖 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.rb` around lines 247 - 249,
Replace insecure YAML::load calls used to populate `@props` and recOverrideProps
with YAML.safe_load and supply an allowlist of expected classes (e.g., Hash,
Array, String, Integer, Float, TrueClass, FalseClass, NilClass) and permitted
symbols if needed; update the two locations using YAML::load (for filepath and
filepathRecOverride) to call YAML.safe_load(File.read(...), permitted_classes:
[...]) and handle a nil return gracefully (e.g., raise or default to an empty
Hash) so only safe scalar/collection types from the config files are
deserialized.
record-and-playback/core/scripts/sanity/sanity.rb (1)

54-54: ⚡ Quick win

Rename variable to clarify validation intent.

The variable bad_doc is assigned but never used because the function's purpose is to validate XML parsing (relying on exception propagation). The name bad_doc is misleading since the document isn't necessarily bad. Consider renaming to reflect validation intent.

✨ Suggested rename
-  bad_doc = Nokogiri::XML(File.read(filepath)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
+  _doc = Nokogiri::XML(File.read(filepath)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }

Alternatively, remove the assignment entirely if the return value isn't needed:

-  bad_doc = Nokogiri::XML(File.read(filepath)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
+  Nokogiri::XML(File.read(filepath)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
🤖 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/sanity/sanity.rb` at line 54, The variable
bad_doc assigned from Nokogiri::XML(File.read(filepath)) is misleading and
unused; either rename it to reflect validation intent (e.g., parsed_doc or
validation_doc) or remove the assignment entirely and call Nokogiri::XML(...)
for its side-effect (exception on failure). Update the occurrence of bad_doc in
the same scope (the Nokogiri::XML call) to the new name if you keep the
assignment, or replace the assignment with a direct Nokogiri::XML(...)
invocation if you choose to drop the unused variable.
record-and-playback/screenshare/scripts/process/screenshare.rb (1)

167-167: ⚡ Quick win

Prefer JSON.parse over JSON.load for captions input.

JSON.parse is the safer and intended API for plain JSON text here.

♻️ Proposed fix
-captions = JSON.load(File.read("#{process_dir}/captions.json"))
+captions = JSON.parse(File.read("#{process_dir}/captions.json"))
🤖 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/process/screenshare.rb` at line 167,
Replace the use of JSON.load with JSON.parse when reading captions.json in the
screenshare.rb assignment to captions (the line assigning captions =
JSON.load(...)); update the code so the file contents are read and passed to
JSON.parse instead of JSON.load to avoid potential unsafe object deserialization
and use the intended plain-JSON API.
🤖 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/post_events/post_events_analytics_callback.rb`:
- Line 180: Replace JSON.load with JSON.parse to avoid unsafe deserialization:
in post_events_analytics_callback.rb locate the line where data is assigned
(data = JSON.load(File.read(data_json_path))) and change it to use
JSON.parse(File.read(data_json_path)); ensure the file still requires 'json' if
not already and keep the surrounding logic (variable data and variable
data_json_path) unchanged.

In `@record-and-playback/core/scripts/rap-process-worker.rb`:
- Line 140: Replace the unsafe YAML::load call that populates the props variable
with YAML.safe_load; locate the line using YAML::load (the props = ...
assignment) and change it to use YAML.safe_load(File.read('bigbluebutton.yml'),
...) and explicitly supply permitted_classes and permitted_symbols (or an empty
list) as appropriate for your config so only expected types are allowed; if you
rely on aliases, enable the aliases option.

In `@record-and-playback/core/scripts/utils/captions.rb`:
- Line 57: The line assigning captions uses JSON.load which can deserialize
arbitrary Ruby objects; change it to use JSON.parse to safely parse only JSON
primitives: locate the assignment to captions (the variable reading
"#{captions_meeting_dir}/captions_playback.json") and replace
JSON.load(File.read(...)) with JSON.parse(File.read(...)), keeping the file read
behavior and variable name unchanged so captions retains the parsed JSON
structure.
- Line 41: The assignment using YAML::load to populate props is unsafe; change
the call to use YAML.safe_load when reading
'../../core/scripts/bigbluebutton.yml' (i.e., replace the YAML::load call used
in the props = ... line) and supply explicit permitted_classes (empty array if
no complex objects are expected) and enable aliases only if required so the
config is parsed safely without allowing arbitrary object deserialization.

In `@record-and-playback/notes/scripts/process/notes.rb`:
- Around line 41-42: Replace the unsafe YAML parsing and the unclosed File.open:
change the two YAML::load(File.read(...)) usages that populate props and
notes_props to use YAML.safe_load(File.read(...)) (no aliases option needed),
and replace the remaining bare File.open usage with either File.read(...) or a
block-style File.open(...){|f| ... } so the file descriptor is closed; target
the variables props and notes_props and the lone File.open call in notes.rb when
making the changes.

In `@record-and-playback/notes/scripts/publish/notes.rb`:
- Around line 33-34: Replace the unsafe YAML::load calls used to populate
bbb_props and notes_props with YAML.safe_load; specifically change the two
expressions that call YAML::load(File.read(...)) to
YAML.safe_load(File.read(...)) and, if the YAML files require deserialization of
non-scalar types (e.g., Date, Time, Symbol) or aliases, pass an explicit
permitted_classes/permitted_symbols array and aliases: true to safe_load so you
only allow the needed classes rather than enabling arbitrary object
deserialization.

In `@record-and-playback/podcast/scripts/process/podcast.rb`:
- Around line 41-42: The code uses YAML::load to parse config files into props
and podcast_props which is unsafe; replace YAML::load with YAML.safe_load for
both parses (YAML::load -> YAML.safe_load) and pass safe_load options (e.g.,
aliases: true only if anchors/aliases are used, and explicitly set
permitted_classes/permitted_symbols if you need non-scalar types), ensuring you
update the two occurrences that read '../../core/scripts/bigbluebutton.yml' and
'podcast.yml' where props and podcast_props are assigned.

In `@record-and-playback/screenshare/scripts/publish/screenshare.rb`:
- Line 77: The code uses JSON.load(File.read("#{process_dir}/captions.json"))
which can deserialize arbitrary Ruby objects; change it to use
JSON.parse(File.read("#{process_dir}/captions.json")) so only JSON is parsed
(update the expression where captions is assigned and keep the same
process_dir/captions.json reference).

---

Duplicate comments:
In `@record-and-playback/screenshare/scripts/publish/screenshare.rb`:
- Around line 40-41: The YAML loading calls using YAML::load for variables props
and screenshare_props are unsafe; replace them with YAML.safe_load, passing the
file contents and a permitted classes/aliases list or set permitted_classes: [],
aliases: true/false as needed to avoid executing arbitrary Ruby objects; update
the two occurrences (the expressions creating props and screenshare_props) to
call YAML.safe_load(File.read(...), permitted_classes: [], aliases: false) or an
appropriate safe configuration for the expected YAML content.

---

Nitpick comments:
In `@record-and-playback/core/lib/recordandplayback.rb`:
- Around line 247-249: Replace insecure YAML::load calls used to populate `@props`
and recOverrideProps with YAML.safe_load and supply an allowlist of expected
classes (e.g., Hash, Array, String, Integer, Float, TrueClass, FalseClass,
NilClass) and permitted symbols if needed; update the two locations using
YAML::load (for filepath and filepathRecOverride) to call
YAML.safe_load(File.read(...), permitted_classes: [...]) and handle a nil return
gracefully (e.g., raise or default to an empty Hash) so only safe
scalar/collection types from the config files are deserialized.

In `@record-and-playback/core/scripts/sanity/sanity.rb`:
- Line 54: The variable bad_doc assigned from Nokogiri::XML(File.read(filepath))
is misleading and unused; either rename it to reflect validation intent (e.g.,
parsed_doc or validation_doc) or remove the assignment entirely and call
Nokogiri::XML(...) for its side-effect (exception on failure). Update the
occurrence of bad_doc in the same scope (the Nokogiri::XML call) to the new name
if you keep the assignment, or replace the assignment with a direct
Nokogiri::XML(...) invocation if you choose to drop the unused variable.

In `@record-and-playback/screenshare/scripts/process/screenshare.rb`:
- Line 167: Replace the use of JSON.load with JSON.parse when reading
captions.json in the screenshare.rb assignment to captions (the line assigning
captions = JSON.load(...)); update the code so the file contents are read and
passed to JSON.parse instead of JSON.load to avoid potential unsafe object
deserialization and use the intended plain-JSON API.
🪄 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: 0ac35669-5136-4770-befb-311b5205054c

📥 Commits

Reviewing files that changed from the base of the PR and between 902e4d8 and 078c047.

📒 Files selected for processing (29)
  • record-and-playback/core/lib/recordandplayback.rb
  • record-and-playback/core/lib/recordandplayback/events_archiver.rb
  • record-and-playback/core/lib/recordandplayback/generators/audio_processor.rb
  • record-and-playback/core/lib/recordandplayback/generators/events.rb
  • record-and-playback/core/lib/recordandplayback/generators/presentation.rb
  • record-and-playback/core/lib/recordandplayback/generators/video.rb
  • record-and-playback/core/lib/recordandplayback/workers/events_worker.rb
  • record-and-playback/core/scripts/archive/archive.rb
  • record-and-playback/core/scripts/bbb-0.9-beta-recording-update
  • record-and-playback/core/scripts/bbb-0.9-recording-size
  • record-and-playback/core/scripts/bbb-1.1-meeting-tag
  • record-and-playback/core/scripts/post_events/post_events.rb.example
  • record-and-playback/core/scripts/post_events/post_events_analytics_callback.rb
  • record-and-playback/core/scripts/rap-caption-inbox.rb
  • record-and-playback/core/scripts/rap-process-worker.rb
  • record-and-playback/core/scripts/sanity/sanity.rb
  • record-and-playback/core/scripts/utils/captions.rb
  • record-and-playback/core/test/recordandplayback/generators/test_events.rb
  • record-and-playback/notes/scripts/process/notes.rb
  • record-and-playback/notes/scripts/publish/notes.rb
  • record-and-playback/podcast/scripts/process/podcast.rb
  • record-and-playback/podcast/scripts/publish/podcast.rb
  • record-and-playback/presentation/scripts/caption/presentation
  • record-and-playback/presentation/scripts/process/presentation.rb
  • record-and-playback/presentation/scripts/publish/presentation.rb
  • record-and-playback/screenshare/scripts/process/screenshare.rb
  • record-and-playback/screenshare/scripts/publish/screenshare.rb
  • record-and-playback/video/scripts/process/video.rb
  • record-and-playback/video/scripts/publish/video.rb
✅ Files skipped from review due to trivial changes (2)
  • record-and-playback/core/scripts/post_events/post_events.rb.example
  • record-and-playback/core/scripts/bbb-0.9-recording-size

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@defnull

defnull commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Still not tested (because I lack a proper test environment) but I think I got everything.

@defnull defnull changed the title [WIP] fix(recording): Avoid leaking file handles in ruby scripts. fix(recording): Avoid leaking file handles in ruby scripts. May 22, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

This pull request has conflicts ☹
Please resolve those so we can review the pull request.
Thanks.

@antobinary

Copy link
Copy Markdown
Member

Closed via #25952 in BBB 4.0. Thank you!

@antobinary antobinary closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants