-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: supply system log to trusted plugins via FD (#5391)
* feat: supply system log to trusted plugins via FD * chore: add comment about extracting * chore: update test name * fix: tests * refactor: extract isTrustedPlugin * refactor: provide via "systemLog" function * fix: add systemLog to types
- Loading branch information
Showing
9 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { appendFileSync, openSync } from 'fs' | ||
|
||
const systemLogLocation = '/dev/fd/4' | ||
|
||
export const getSystemLog = () => { | ||
try { | ||
// throws if system log wasn't hooked up | ||
const fd = openSync(systemLogLocation, 'a') | ||
return (message) => { | ||
appendFileSync(fd, `${message}\n`) | ||
} | ||
} catch { | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const onBuild = function ({ featureFlags }) { | ||
export const onBuild = function ({ featureFlags, systemLog }) { | ||
systemLog?.("some system-facing logs") | ||
console.log(JSON.stringify(featureFlags)) | ||
} |
5 changes: 4 additions & 1 deletion
5
packages/build/tests/plugins/fixtures/feature_flags_untrusted/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export const onBuild = function ({ featureFlags }) { | ||
export const onBuild = function ({ featureFlags, systemLog }) { | ||
if (systemLog) { | ||
throw new Error("System log shouldn't be acessible from untrusted plugins") | ||
} | ||
console.log("typeof featureflags:", typeof featureFlags) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters