Skip to content

Commit

Permalink
update README, fix newline issue in cmd output
Browse files Browse the repository at this point in the history
  • Loading branch information
juerkkil committed Dec 26, 2024
1 parent 36c74ad commit 7c31257
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,51 @@ $ pip install secheaders

## Usage
```
$ secheaders --help
usage: secheaders [-h] [--max-redirects N] [--insecure] [--json] [--no-color]
[--verbose]
URL
usage: secheaders [-h] [--target-list FILE] [--max-redirects N] [--insecure] [--json] [--no-color] [--verbose] [URL]
Scan HTTP security headers
positional arguments:
URL Target URL
URL Target URL (default: None)
options:
-h, --help show this help message and exit
--max-redirects N Max redirects, set 0 to disable (default: 2)
--insecure Do not verify TLS certificate chain (default: False)
--json JSON output instead of text (default: False)
--no-color Do not output colors in terminal (default: False)
--verbose, -v Verbose output (default: False)
-h, --help show this help message and exit
--target-list FILE Read multiple target URLs from a file and scan them all (default: None)
--max-redirects N Max redirects, set 0 to disable (default: 2)
--insecure Do not verify TLS certificate chain (default: False)
--json JSON output instead of text (default: False)
--no-color Do not output colors in terminal (default: False)
--verbose, -v Verbose output (default: False)
```


## Example output
```
$ secheaders example.com
Scanning target https://example.com ...
Header 'x-frame-options' is missing [ WARN ]
Header 'strict-transport-security' is missing [ WARN ]
Header 'content-security-policy' is missing [ WARN ]
Header 'x-content-type-options' is missing [ WARN ]
Header 'x-xss-protection' is missing [ OK ]
Header 'referrer-policy' is missing [ WARN ]
Header 'permissions-policy' is missing [ WARN ]
server: ECAcc (nyd/D147) [ WARN ]
server: ECAcc (nyd/D191) [ WARN ]
HTTPS supported [ OK ]
HTTPS valid certificate [ OK ]
HTTP -> HTTPS automatic redirect [ WARN ]
```

## Design principles

The following design principles have been considered:

* Simplicity of the codebase.
* Simplicity of the codebase.
* The code should be easy to understand and follow without in-depth Python knowledge.
* Avoidance of external dependencies.
* The Python Standard Libary provides enough tools and libraries for quite many use cases.
* Unix philosophy in general
* Unix philosophy in general
* *"Do one thing and do it well"*

These are not rules set in stone, but should be revisited when doing big design choices.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Repository = "https://github.com/juerkkil/secheaders"


[project.scripts]
secheaders = "secheaders.securityheaders:main"
secheaders = "secheaders.secheaders:main"
5 changes: 2 additions & 3 deletions secheaders/cmd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ def output_text(target_url, headers, https, no_color=False, verbose=False) -> st
output = f"{msg_map[key]}"
eval_value = get_eval_output(not https[key], no_color)
if no_color:
output = f"{output:<{terminal_width - COLUMN_WIDTH_R}}{eval_value:^{COLUMN_WIDTH_R}}"
output = f"{output:<{terminal_width - COLUMN_WIDTH_R}}{eval_value:^{COLUMN_WIDTH_R}}\n"
else:
# This is a dirty hack required to align ANSI-colored str correctly
output = f"{output:<{terminal_width - COLUMN_WIDTH_R}}{eval_value:^{COLUMN_WIDTH_R + 9}}"
output = f"{output:<{terminal_width - COLUMN_WIDTH_R}}{eval_value:^{COLUMN_WIDTH_R + 9}}\n"

output_str += output

output_str += '\n'
return output_str
2 changes: 1 addition & 1 deletion secheaders/secheaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main():
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('url', metavar='URL', nargs='?', default=None, type=str, help='Target URL')
parser.add_argument('--target-list', dest='target_list', metavar='FILE', default=None, type=str,
help='Input from list of target URLs')
help='Read multiple target URLs from a file and scan them all')
parser.add_argument('--max-redirects', dest='max_redirects', metavar='N', default=2, type=int,
help='Max redirects, set 0 to disable')
parser.add_argument('--insecure', dest='insecure', action='store_true',
Expand Down

0 comments on commit 7c31257

Please sign in to comment.