Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
¿Cómo usar HTML onselect sin violar CSP?

Entonces, lo que estoy tratando de hacer es cuando alguien selecciona un elemento del formulario 'seleccionar' , hace algo que se ha definido en la función "showPost ()" en la sección del script. y CSP sigue rechazando mi operación :(

Probé CSP hash y CSP nonce. y ambos no funcionan.

Si aplico 'inseguro en línea' funciona, por lo que la función no tiene problema.

¿Qué debería estar mal?

PD : estoy usando un estilo CSS personalizado dentro del archivo HTML (EJS), así que también hice un trabajo hash de CSP en la configuración de CSP styleSrc. Y funciona bien.

1. Mensaje de error

imagen de error

2. Mi formulario de selección

imagen de seleccionar de

3. Código

Parte del archivo HTML (EJS)

 <select class="form-select" aria-label="Order of Aboutme" id="aboutmeOrder" onchange="showPost()"> <option selected>글 순서를 정해주세요..</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> .... .... <script nonce="example"> function showPost(){ var select = document.getElementById("aboutmeOrder").value; console.log(select); } </script>

Parte del archivo index.js

 const csp = require('helmet-csp'); app.use(helmet()); app.use( csp({ directives: { defaultSrc: ["'self'"], styleSrc: ["'self' 'sha256-uts7zrnGYAKZNfvBc7PYcShvKP4t10vo5qemd5Yp0lc=' https://cdn.jsdelivr.net/"], scriptSrc: [`'self' 'sha256-RemzkHuAMqaMxa/UriyGSEioInZdZJpm6lnkGuugweU=' 'nonce-example' https://cdn.jsdelivr.net/`], }, }) );
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

nvm, tengo la respuesta

tienes que usar 'hashes inseguros' o tienes que usar el archivo js.

https://content-security-policy.com/unsafe-hashes/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!