Skip to content

Commit

Permalink
Prevent accidental commits of hacked legal.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed Nov 22, 2018
1 parent 362c381 commit aa6097b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 22 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ app/
!frontend/src/app
uploads/complaints/*.*
!uploads/complaints/.gitkeep

# Tests
test/files/legal.md
ftp/legal.md

# Build
.nyc_output/
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function (grunt) {
'frontend/dist/frontend/**',
'config/*.yml',
'data/*.js',
'data/static/*.yml',
'data/static/**',
'encryptionkeys/**',
'ftp/**',
'lib/**',
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions lib/startup/restoreOriginalLegalInformation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path')
const fs = require('fs-extra')

const restoreOriginalLegalInformation = () => {
fs.copyFileSync(path.resolve(__dirname, '../../data/static/legal.md'), path.resolve(__dirname, '../../ftp/legal.md'))
}

module.exports = restoreOriginalLegalInformation
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ errorhandler.title = `${config.get('application.name')} (Express ${utils.version
require('./lib/startup/validatePreconditions')()
require('./lib/startup/validateConfig')()
require('./lib/startup/cleanupFtpFolder')()
require('./lib/startup/restoreOriginalLegalInformation')()

/* Locals */
app.locals.captchaId = 0
Expand Down
18 changes: 0 additions & 18 deletions test/api/fileUploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@ const utils = require('../../lib/utils')
const URL = 'http://localhost:3000'

describe('/file-upload', () => {
beforeAll((done) => {
fs.copyFile(path.resolve(__dirname, '../../ftp/legal.md'), path.resolve(__dirname, '../files/legal.md'), (err) => {
if (err) {
console.log('Error backing up original legal.md file: ' + err.message)
}
done()
})
})

afterAll((done) => {
fs.copyFile(path.resolve(__dirname, '../files/legal.md'), path.resolve(__dirname, '../../ftp/legal.md'), (err) => {
if (err) {
console.log('Error restoring backup of original legal.md file: ' + err.message)
}
done()
})
})

it('POST file valid PDF for client and API', () => {
const file = path.resolve(__dirname, '../files/validSizeAndTypeForClient.pdf')
const form = frisby.formData()
Expand Down

0 comments on commit aa6097b

Please sign in to comment.