Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@bgoodman/react-console-component
Advanced tools
A unix-style text console as a React component.
A React component that provides a console-like interface for displaying the output of commands and to capture user input. The component itself does not provide any functionality for executing commands.
Try the demo here.
npm install @bgoodman/react-console-component
import { Console } from '@bgoodman/react-console-component'
const App = () => {
const onInit = (): Promise<string> => {
// do something when the console is initialized.
const output = new Date().toString()
// return the console output as a promise.
return Promise.resolve(output)
}
const evalCmd = (cmd) => {
try {
// do something with the input command.
const result = eval(cmd).toString()
// return the result as a promise
return Promise.resolve(result)
} catch (err) {
return Promise.resolve(err.toString())
}
}
return (
<Console
onEnter={execCode}
onInit={onInit}
prompt="$"
height="300px"
autoScroll
/>
)
}
Prop | Type | Default | Description |
---|---|---|---|
onEnter | (cmd: string) => Promise<string> | undefined | Function to execute when the user presses 'Enter'. |
onInit | () => Promise<string> | undefined | Function to execute when the console is initialized. |
prompt | string | "$" | The prompt string. |
height | string | "300px" | The height of the console. |
autoScroll | boolean | true | If true, the console will automatically scroll to the bottom when new content is added. |
theme | Theme | See 'Themes' section. | A custom theme to use for the console. If not provided, the default light theme will be used. |
The console component uses the styled-components
library to style the console. You can provide your own theme by passing a Theme
object to the theme
prop. For example, the default theme is defined as:
import { type Theme } from '@bgoodman/react-console-component'
const lightTheme: Theme = {
font: {
size: '16px',
family: 'monospace'
},
colors: {
background: '#FFFFFF',
text: '#5F6368'
},
}
Additional themes can be defined as needed. For example, a dark theme could be defined as:
const darkTheme: Theme = {
font: {
size: '16px',
family: 'monospace'
},
colors: {
background: '#272822',
text: '#F8F8F2'
},
}
The console component reserves the following commands:
clear
- Clears the console output.FAQs
A unix-style text console as a React component.
The npm package @bgoodman/react-console-component receives a total of 0 weekly downloads. As such, @bgoodman/react-console-component popularity was classified as not popular.
We found that @bgoodman/react-console-component demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.