Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add command-line interface #84

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MFTabriz
Copy link

@MFTabriz MFTabriz commented Jan 22, 2025

Add a command-line interface (CLI) to facilitate easier interaction with the library, enabling users to run it directly from the terminal. The CLI supports output in both JSON and human-readable formats. If any errors are encountered in the security.txt file, the program will exit with a status code of 1.

> sectxt --help
usage: sectxt [-h] [--json] [--show-notifications] [--show-recommendations] [--no-recommend-unknown-fields] [--version] address

Parse and validate security.txt

positional arguments:
  address               website URL or path to local file to check

options:
  -h, --help            show this help message and exit
  --json                output the results in JSON format
  --show-notifications  show notifications
  --show-recommendations
                        show recommendations
  --no-recommend-unknown-fields
                        do not issue notifications for unknown fields
  --version             show program's version number and exit
> sectxt --show-recommendation --show-notification ./security.txt 
[ERROR] L6: no_line_separators : Every line, including the last one, must end with either a carriage return and line feed characters or just a line feed character
[REC] no_encryption : 'Encryption' field should be present when 'Contact' field contains an email address.
[REC] not_signed : security.txt should be digitally signed.
[NOTE] L6: unknown_field : security.txt contains an unknown field. Field "test_unknown" is either a custom field which may not be widely supported, or there is a typo in a standardised field name.
> sectxt --show-recommendation --show-notification --json ./security.txt
[{'code': 'no_line_separators', 'message': 'Every line, including the last one, must end with either a carriage return and line feed characters or just a line feed character', 'line': 6, 'type': 'ERROR'}, {'code': 'no_encryption', 'message': "'Encryption' field should be present when 'Contact' field contains an email address.", 'line': None, 'type': 'REC'}, {'code': 'not_signed', 'message': 'security.txt should be digitally signed.', 'line': None, 'type': 'REC'}, {'code': 'unknown_field', 'message': 'security.txt contains an unknown field. Field "test_unknown" is either a custom field which may not be widely supported, or there is a typo in a standardised field name.', 'line': 6, 'type': 'NOTE'}]

@MFTabriz
Copy link
Author

MFTabriz commented Jan 22, 2025

@DigitalTrustCenter Before proceeding to document this in the README file, I would appreciate your opinion on the following:

  • Are the argument names clear and intuitive for users familiar with the library?
  • What approach would you recommend for testing this functionality?

EDIT: I went ahead and added CLI information to the documentation.

@MFTabriz MFTabriz force-pushed the main branch 2 times, most recently from f86ba3f to 29213ca Compare January 22, 2025 16:32
@MFTabriz MFTabriz marked this pull request as ready for review January 30, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant