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.
storybook-source-code-addon
Advanced tools
This is an addon for Storybook. It purpose is to allow anyone navigating your storybook to access the source code. It was implemented as an alternative to regular libraries, and to allow the end user to copy and paste your code instead of using it as a library.
It's pretty simple actually:
$ yarn add -D @storybook-source-code-addon
.storybook/main.js
module.exports = {
addons: ['storybook-source-code-addon']
}
If you happen to have your source code in a string, all you need is to add it to your story:
export default {
title: 'Your story',
parameters: {
componentSource: {
code: 'export default "This is my code"',
language: 'javascript',
}
},
};
With this approach, we recommend using a code file:
// MyComponent.code.js
export default `
const MyComponent = () => "Hello World"
`
import MyComponentCode from './MyComponent.code'
export default {
title: 'Your story',
parameters: {
componentSource: {
code: MyComponentCode,
language: 'javascript',
}
},
};
If your repository is publicly hosted, you can provide a url to your file to the addon:
export default {
title: 'Your story',
parameters: {
componentSource: {
url: 'https://path.to.your.repository/file%2Etsx',
language: 'javascript',
}
},
};
Common providers API include
https://gitlab.com/api/v4/projects/<ProjectID>/repository/files/<file path URL encoded>/raw?ref=master
for GitLabIf you want to expose multiple files, you can do as follow:
export default {
title: 'Your story',
parameters: {
componentSource: {
url: [
'https://path.to.your.repository/file%2Etsx',
'https://path.to.your.repository/file2%2Etsx',
],
language: 'javascript',
}
},
};
or
export default {
title: 'Your story',
parameters: {
componentSource: {
code: [
'export default "This is my code"',
'export default "This is also my code"',
],
language: 'javascript',
}
},
};
FAQs
## What is it?
We found that storybook-source-code-addon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.