<commit_before>const path = require('path')
const url = require('url')
module.exports = (request, response) => {

  response.sendFile(path.join(process.env.BUILDPATH, url.parse(request.url).pathname));
}<commit_msg>fix security bug in static handler<commit_after>const path = require('path')
const url = require('url')
module.exports = (request, response) => {
  var file = path.join(process.env.BUILDPATH, url.parse(request.url).pathname)

  // prevent sending files outside project folder.
  if (!require('path').relative(process.env.BUILDPATH, file).startsWith("..") ){
    response.sendFile(file);
  }
  else{
    response.sendStatus(404)
  }
}
{'fraction_non_alphanumeric': 0.16203703703703703, 'fraction_numerical': 0.004629629629629629, 'mean_word_length': 5.065420560747664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5696672', 'n_tokens_mistral': 203, 'n_tokens_neox': 203, 'n_words': 41}