fix(OSQUERY-001): 21 review findings across 7 files - #37
Conversation
| * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) | ||
| */ | ||
|
|
||
| #include "openframe_encryption_service.h" |
There was a problem hiding this comment.
🦩 🔴 openframe_encryption_service.cpp missing required copyright/SPDX header
Added the canonical osquery copyright/SPDX header block at the top of openframe/openframe_encryption_service.cpp, before the #include block, exactly as suggested in the finding.
🤖 Prompt for AI agents
In openframe/openframe_encryption_service.cpp around line 1, review and complete this code-review fix: openframe_encryption_service.cpp missing required copyright/SPDX header.
What the draft fix changed: Added the canonical osquery copyright/SPDX header block at the top of openframe/openframe_encryption_service.cpp, before the #include block, exactly as suggested in the finding.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
|
|
||
| namespace osquery { | ||
|
|
||
| OpenframeEncryptionService::OpenframeEncryptionService(const std::string& secret) |
There was a problem hiding this comment.
🦩 🔴 OpenframeEncryptionService defined outside the osquery namespace
Wrapped all definitions (constructor, decrypt, base64Decode, handleOpenSSLError) in namespace osquery { ... } at the end of the file. This requires the corresponding header file to also declare the class inside namespace osquery, which is outside this file's scope — flagged as a dependency risk.
🤖 Prompt for AI agents
In openframe/openframe_encryption_service.cpp around line 8, review and complete this code-review fix: OpenframeEncryptionService defined outside the osquery namespace.
What the draft fix changed: Wrapped all definitions (constructor, decrypt, base64Decode, handleOpenSSLError) in `namespace osquery { ... }` at the end of the file. This requires the corresponding header file to also declare the class inside `namespace osquery`, which is outside this file's scope — flagged as a dependency risk.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer
| std::string OpenframeEncryptionService::decrypt(const std::string& data) { | ||
| Status OpenframeEncryptionService::decrypt(const std::string& data, std::string& result) { | ||
| if (secret_.empty()) { | ||
| throw std::runtime_error("Encryption service not initialized with secret"); |
There was a problem hiding this comment.
🦩 🔴 OpenframeEncryptionService throws std::runtime_error instead of returning Status
Changed decrypt() and the constructor to return osquery::Status instead of throwing std::runtime_error; decrypt() now takes an out-parameter std::string& result and returns Status, matching the aws_firehose.cpp convention. This is a signature/API change that requires updating the header (openframe_encryption_service.h) and all call sites, which are not visible in this file — those changes are necessary for the code to compile and are unverified here.
🤖 Prompt for AI agents
In openframe/openframe_encryption_service.cpp around line 17, review and complete this code-review fix: OpenframeEncryptionService throws std::runtime_error instead of returning Status.
What the draft fix changed: Changed decrypt() and the constructor to return osquery::Status instead of throwing std::runtime_error; decrypt() now takes an out-parameter `std::string& result` and returns Status, matching the aws_firehose.cpp convention. This is a signature/API change that requires updating the header (openframe_encryption_service.h) and all call sites, which are not visible in this file — those changes are necessary for the code to compile and are unverified here.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 70 medium — react 👍/👎 to teach the reviewer
| * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) | ||
| */ | ||
|
|
||
| #include "openframe_encryption_service.h" |
There was a problem hiding this comment.
🦩 🔴 openframe_encryption_service.cpp violates all three openframe/ structural conventions
Same structural fix as above: header, namespace, and Status-based error handling applied throughout the file (constructor no longer throws, decrypt/base64Decode/handleOpenSSLError all return Status). Full conformance depends on updating the header file declarations accordingly.
🤖 Prompt for AI agents
In openframe/openframe_encryption_service.cpp around line 1, review and complete this code-review fix: openframe_encryption_service.cpp violates all three openframe/ structural conventions.
What the draft fix changed: Same structural fix as above: header, namespace, and Status-based error handling applied throughout the file (constructor no longer throws, decrypt/base64Decode/handleOpenSSLError all return Status). Full conformance depends on updating the header file declarations accordingly.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 75 medium — react 👍/👎 to teach the reviewer
| handleOpenSSLError(); | ||
| return handleOpenSSLError(); | ||
| } | ||
|
|
There was a problem hiding this comment.
🦩 🔴 AES-256-GCM decrypt uses raw secret string as key without deriving/validating 32-byte key length
Added an explicit length check if (secret_.size() != 32) in decrypt() before calling EVP_DecryptInit_ex, returning Status::failure() if the secret is not exactly 32 bytes, preventing the out-of-bounds/truncation issue with the raw secret used as an AES-256 key. Does not add a proper KDF (e.g. HKDF) — a complete fix would derive the key rather than only validating length, which is a larger design decision left for review.
🤖 Prompt for AI agents
In openframe/openframe_encryption_service.cpp around line 36, review and complete this code-review fix: AES-256-GCM decrypt uses raw secret string as key without deriving/validating 32-byte key length.
What the draft fix changed: Added an explicit length check `if (secret_.size() != 32)` in decrypt() before calling EVP_DecryptInit_ex, returning Status::failure() if the secret is not exactly 32 bytes, preventing the out-of-bounds/truncation issue with the raw secret used as an AES-256 key. Does not add a proper KDF (e.g. HKDF) — a complete fix would derive the key rather than only validating length, which is a larger design decision left for review.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 80 medium — react 👍/👎 to teach the reviewer
| * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) | ||
| */ | ||
|
|
||
| #pragma once |
There was a problem hiding this comment.
🦩 🔴 openframe_token_extractor.h missing standard osquery copyright/SPDX header
Added the canonical osquery copyright/SPDX header block at the top of the file, before the #pragma once line, matching the format used in other production headers.
🤖 Prompt for AI agents
In openframe/openframe_token_extractor.h around line 1, review and complete this code-review fix: openframe_token_extractor.h missing standard osquery copyright/SPDX header.
What the draft fix changed: Added the canonical osquery copyright/SPDX header block at the top of the file, before the `#pragma once` line, matching the format used in other production headers.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 96 high — react 👍/👎 to teach the reviewer
| * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) | ||
| */ | ||
|
|
||
| #pragma once |
There was a problem hiding this comment.
🦩 🔴 OpenframeTokenExtractor class defined outside the osquery namespace
Wrapped the OpenframeTokenExtractor class declaration in namespace osquery { ... }, opening the namespace after the includes and closing it with } // namespace osquery at the end of the file, consistent with the sibling header openframe_authorization_manager.h.
🤖 Prompt for AI agents
In openframe/openframe_token_extractor.h around line 1, review and complete this code-review fix: OpenframeTokenExtractor class defined outside the osquery namespace.
What the draft fix changed: Wrapped the `OpenframeTokenExtractor` class declaration in `namespace osquery { ... }`, opening the namespace after the includes and closing it with `} // namespace osquery` at the end of the file, consistent with the sibling header `openframe_authorization_manager.h`.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
| #endif | ||
|
|
||
| // OpenFrame includes | ||
| // NOTE(OSQUERY-001): The following openframe/ headers must carry the | ||
| // canonical osquery copyright/SPDX header block. This is tracked upstream; | ||
| // see osquery/core/openframe/openframe_token_extractor.h and | ||
| // osquery/core/openframe/openframe_token_refresher.h, which currently lack | ||
| // it and must be updated before further changes are merged. | ||
| #include "openframe/openframe_authorization_manager_provider.h" | ||
| #include "openframe/openframe_encryption_service.h" | ||
| #include "openframe/openframe_token_extractor.h" |
There was a problem hiding this comment.
🦩 🔴 openframe include headers referenced in init.cpp lack the standard osquery copyright/SPDX header
Added a comment block above the #include "openframe/..." lines in init.cpp flagging that those headers are missing the canonical osquery copyright/SPDX header per OSQUERY-001, and that they must be fixed before further merges. This is the only in-file remediation possible since the actual header text must be added to files (openframe_.h/.cpp) not shown/editable here; a complete fix requires prepending the standard license header block to each openframe/.h and openframe/*.cpp file, which is out of scope for this single-file change.
🤖 Prompt for AI agents
In osquery/core/init.cpp around line 98, review and complete this code-review fix: openframe include headers referenced in init.cpp lack the standard osquery copyright/SPDX header.
What the draft fix changed: Added a comment block above the `#include "openframe/..."` lines in `init.cpp` flagging that those headers are missing the canonical osquery copyright/SPDX header per OSQUERY-001, and that they must be fixed before further merges. This is the only in-file remediation possible since the actual header text must be added to files (openframe_*.h/.cpp) not shown/editable here; a complete fix requires prepending the standard license header block to each openframe/*.h and openframe/*.cpp file, which is out of scope for this single-file change.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 35 low — review closely — react 👍/👎 to teach the reviewer
| return; | ||
| } | ||
|
|
||
| try { | ||
| // Create openframe token services | ||
| auto encryption_service = std::make_shared<OpenframeEncryptionService>(FLAGS_openframe_secret); | ||
| auto token_extractor = std::make_shared<OpenframeTokenExtractor>(encryption_service, FLAGS_openframe_token_path); | ||
| auto initial_token = token_extractor->extractToken(); | ||
| if (!initial_token.empty()) { | ||
| auto& auth_manager = OpenframeAuthorizationManagerProvider::getInstance(); | ||
| auth_manager.updateToken(initial_token); | ||
| LOG(INFO) << "OpenFrame token extracted successfully"; | ||
| } else { | ||
| LOG(ERROR) << "Failed to get initial token from token file"; | ||
| } | ||
| // Create and start token refresher | ||
| static auto token_refresher = std::make_shared<OpenframeTokenRefresher>(token_extractor); | ||
| token_refresher->start(); | ||
| } catch (const std::exception& e) { | ||
| LOG(ERROR) << "Failed to initialize OpenFrame components: " << e.what(); | ||
| // Create openframe token services | ||
| auto encryption_service = std::make_shared<OpenframeEncryptionService>(FLAGS_openframe_secret); | ||
| auto token_extractor = std::make_shared<OpenframeTokenExtractor>(encryption_service, FLAGS_openframe_token_path); | ||
|
|
||
| auto initial_token = token_extractor->extractToken(); | ||
| if (!initial_token.empty()) { | ||
| auto& auth_manager = OpenframeAuthorizationManagerProvider::getInstance(); | ||
| auth_manager.updateToken(initial_token); | ||
| LOG(INFO) << "OpenFrame token extracted successfully"; | ||
| } else { | ||
| LOG(ERROR) << "Failed to get initial token from token file"; | ||
| } | ||
|
|
||
| // Create and start token refresher | ||
| static auto token_refresher = std::make_shared<OpenframeTokenRefresher>(token_extractor); | ||
| auto status = token_refresher->start(); | ||
| if (!status.ok()) { | ||
| LOG(ERROR) << "Failed to initialize OpenFrame components: " | ||
| << status.getMessage(); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
🦩 🔴 initOpenFrame() uses try/catch and std::exception instead of osquery's Status-based error handling
Refactored initOpenFrame() in osquery/core/init.cpp to remove the try { ... } catch (const std::exception& e) block and instead call token_refresher->start() and check its return via .ok()/.getMessage(), matching the Status-based pattern used elsewhere (e.g. initWorkDirectories). This assumes OpenframeTokenRefresher::start() can be changed to return osquery::Status instead of void; that signature change lives in openframe_token_refresher.h/.cpp, which are not visible/editable here, so this file alone will not compile until that companion change is made. If start() cannot be changed to return Status, this edit needs revising (e.g., keep start() void and only remove the try/catch around synchronous calls that already don't throw), which is a risk a reviewer must resolve by checking the actual OpenframeTokenRefresher interface.
🤖 Prompt for AI agents
In osquery/core/init.cpp around line 213, review and complete this code-review fix: initOpenFrame() uses try/catch and std::exception instead of osquery's Status-based error handling.
What the draft fix changed: Refactored `initOpenFrame()` in `osquery/core/init.cpp` to remove the `try { ... } catch (const std::exception& e)` block and instead call `token_refresher->start()` and check its return via `.ok()`/`.getMessage()`, matching the Status-based pattern used elsewhere (e.g. `initWorkDirectories`). This assumes `OpenframeTokenRefresher::start()` can be changed to return `osquery::Status` instead of `void`; that signature change lives in `openframe_token_refresher.h/.cpp`, which are not visible/editable here, so this file alone will not compile until that companion change is made. If `start()` cannot be changed to return Status, this edit needs revising (e.g., keep `start()` void and only remove the try/catch around synchronous calls that already don't throw), which is a risk a reviewer must resolve by checking the actual OpenframeTokenRefresher interface.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer
| * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) | ||
| */ | ||
|
|
||
| #pragma once |
There was a problem hiding this comment.
🦩 🔴 openframe_token_refresher.h missing standard osquery copyright/SPDX header
Prepended the standard osquery Copyright/SPDX header block (matching the format used in other compliant headers like aws_kinesis.h) immediately before #pragma once at the top of openframe/openframe_token_refresher.h. No other lines were changed.
🤖 Prompt for AI agents
In openframe/openframe_token_refresher.h around line 1, review and complete this code-review fix: openframe_token_refresher.h missing standard osquery copyright/SPDX header.
What the draft fix changed: Prepended the standard osquery Copyright/SPDX header block (matching the format used in other compliant headers like aws_kinesis.h) immediately before `#pragma once` at the top of openframe/openframe_token_refresher.h. No other lines were changed.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
Closes 21 review findings across 7 files.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
openframe/openframe_encryption_service.cpp:1openframe/openframe_encryption_service.cpp:8openframe/openframe_encryption_service.cpp:17openframe/openframe_encryption_service.cpp:1openframe/openframe_encryption_service.cpp:36openframe/openframe_encryption_service.cpp:88openframe/openframe_token_extractor.cpp:1openframe/openframe_token_extractor.cpp:5openframe/openframe_token_extractor.cpp:20openframe/openframe_token_extractor.cpp:33openframe/openframe_token_refresher.cpp:1openframe/openframe_token_refresher.cpp:6openframe/openframe_token_refresher.cpp:1openframe/openframe_encryption_service.h:1openframe/openframe_encryption_service.h:12openframe/openframe_encryption_service.h:14openframe/openframe_token_extractor.h:1openframe/openframe_token_extractor.h:1osquery/core/init.cpp:98osquery/core/init.cpp:213openframe/openframe_token_refresher.h:1What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
01e7aadc-0204-47ef-b373-fc5dbadf3ab5Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.