Skip to content

Commit

Permalink
fixed string escaping security issue
Browse files Browse the repository at this point in the history
  • Loading branch information
raianand authored and dhamijaabhi committed Jul 30, 2024
1 parent a590724 commit 165cbf3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 77 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 18 additions & 67 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ async function run() {
// Run following script before running this action
// npm run render_ejs
// audit script will install auditd and set up audit rules
const { auditScript } = require('./generated/audit-sh')
fs.writeFileSync('audit.sh', auditScript())
const { auditScriptBase64 } = require('./generated/audit-sh')
const auditScript = Buffer.from(auditScriptBase64(), 'base64').toString()
fs.writeFileSync('audit.sh', auditScript)

const { auditRulesTemplate } = require('./audit_rules')

// createBoltUserScript will create a new user for running bolt
const { createBoltUserScript } = require('./generated/create-bolt-user-sh')
fs.writeFileSync('create-bolt-user.sh', createBoltUserScript())
const { createBoltUserScriptBase64 } = require('./generated/create-bolt-user-sh')
const createBoltUserScript = Buffer.from(createBoltUserScriptBase64(), 'base64').toString()
fs.writeFileSync('create-bolt-user.sh', createBoltUserScript)

// iptablesScript will set up iptables rules
const { iptablesScript } = require('./generated/iptables-sh')
fs.writeFileSync('iptables.sh', iptablesScript())
const { iptablesScriptBase64 } = require('./generated/iptables-sh')
const iptablesScript = Buffer.from(iptablesScriptBase64(), 'base64').toString()
fs.writeFileSync('iptables.sh', iptablesScript)

const mode = getMode()
const allowHTTP = getAllowHTTP()
Expand Down
6 changes: 3 additions & 3 deletions src/wrappers/wrapper.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const <%= name %> = () => {
return `<%- body.replace(/`/g, '\\`') %>`
const <%= name %>Base64 = () => {
return '<%- Buffer.from(body).toString('base64') %>'
}

module.exports = {
<%= name %>
<%= name %>Base64
}

0 comments on commit 165cbf3

Please sign in to comment.