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 Shodan Command-Line Interface Plugin #400

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

Conversation

kusshi94
Copy link

@kusshi94 kusshi94 commented Nov 8, 2023

Overview

Add Plugin for Shodan Command-Line Interface.

Type of change

  • Created a new plugin
  • Improved an existing plugin
  • Fixed a bug in an existing plugin
  • Improved contributor utilities or experience

Related Issue(s)

  • Resolves: #
  • Relates: #

How To Test

  • Install Shodan CLI with pip
  • Run op plugin init shodan
  • Run shodan info

Changelog

Authenticate the Shodan Command-Line Interface using Touch ID and other unlock options with 1Password Shell Plugins.

Copy link
Member

@hculea hculea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've left a few questions.

}

func TryShodanConfigFile() sdk.Importer {
return importer.TryFile("~/.config/shodan/api_key", func(ctx context.Context, contents importer.FileContents, in sdk.ImportInput, out *sdk.ImportAttempt) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For many tools, the equivalent of ~/.config from Linux on MacOS is ~/Library/Application Support.

Is this the case here too?

Copy link
Author

@kusshi94 kusshi94 Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking the source code of the CLI tool (https://github.com/achillean/shodan-python/blob/master/shodan/cli/settings.py), it seems that the OS does not matter and the configuration file is stored in ~/.shodan/config if the ~/.shodan/ directory exists. Otherwise, it is stored in ~/.config/shodan/.
I modified the importers to try reading from both locations, and changed the provisioner to use the ~/.shodan/ directory.

func APIKey() schema.CredentialType {
return schema.CredentialType{
Name: credname.APIKey,
DocsURL: sdk.URL("https://developer.shodan.io/api/requirements"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to refer to the API, could we replace this by https://cli.shodan.io/?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced the link with the one you provided.

Comment on lines +16 to +17
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we also exclude shodan init from here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appended needsauth.NotForExactArgs("init") to the arguments of needsauth.IfAll().

@kusshi94
Copy link
Author

@hculea Thank you for your review and suggestions! I have addressed them. Please let me know if the changes are satisfactory or if there are any other modifications I should make.

@kusshi94 kusshi94 requested a review from hculea March 23, 2024 07:11
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.

2 participants