[SOLVED] How to print out content-security-policy

Issue

This Content is from Stack Overflow. Question asked by bizimunda

I have tried this command

curl -Ik https://dev.mydomain.com/

and it does print everything. And now what I want is to print out content-security-policy only.

Do I need to use jq or is there any other helpful tool that I can use?


Solution

curl  -sIk https://stackoverflow.com/ | grep content-security-policy | cut -d ' ' -f 2-

Will curl the url, grep only the line with content-security-policy, cut on a space, and get all the fields from 2 onwards.


Example:

➜  ~ curl  -sIk https://stackoverflow.com/ | grep content-secur | cut -d ' ' -f 2-
upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com

This Question was asked in StackOverflow by bizimunda and Answered by 0stone0 It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?

Exit mobile version