Bird
0
0

In a Django project, you wrote:

medium📝 Debug Q7 of 15
Django - Security Best Practices
In a Django project, you wrote:
response['Content-Security-Policy'] = "default-src 'self'"
response['Content-Security-Policy'] = "script-src 'none'"

What will be the effective CSP header in the response?
A"default-src 'self'"
B"script-src 'none'"
C"default-src 'self'; script-src 'none'"
DNo CSP header will be set
Step-by-Step Solution
Solution:
  1. Step 1: Understand header overwrite behavior

    Setting the same header twice overwrites the previous value in Django response.
  2. Step 2: Identify final header value

    The last assignment "script-src 'none'" replaces the earlier "default-src 'self'".
  3. Final Answer:

    "script-src 'none'" -> Option B
  4. Quick Check:

    Last header assignment wins = "script-src 'none'" [OK]
Quick Trick: Last header assignment overwrites previous ones [OK]
Common Mistakes:
MISTAKES
  • Assuming headers concatenate automatically
  • Expecting both directives combined
  • Thinking no header is set due to conflict

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes