From 18ffb7af614b031f5129affec6f1a5a5702b3b89 Mon Sep 17 00:00:00 2001 From: Brendan Le Glaunec Date: Tue, 3 Feb 2026 12:15:30 +0100 Subject: [PATCH] feat: add version subcommand to help with issues (#400) --- .github/ISSUE_TEMPLATE.md | 57 --------- .github/ISSUE_TEMPLATE/bug_report.yml | 103 +++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 5 + .github/ISSUE_TEMPLATE/feature_request.yml | 31 +++++ CODE_OF_CONDUCT.md | 128 +++++++++++++++++++++ cmd/cameradar/main.go | 22 +++- cmd/cameradar/version.go | 49 ++++++++ 7 files changed, 334 insertions(+), 61 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 cmd/cameradar/version.go diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 0509b37..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,57 +0,0 @@ -Before filing, search open and closed issues and check the FAQ in the README. -If this is a security issue, do not post details in a public issue. -Do not include IPs or any other information that can identify a vulnerable network in your issue. - -## Issue type - -- [ ] Bug report -- [ ] Feature request -- [ ] Documentation issue -- [ ] Question - -## Context - -### Install method - -- [ ] Docker image `ullaakut/cameradar` -- [ ] Custom Docker build -- [ ] Pre-compiled binary -- [ ] Custom binary build -- [ ] Not sure - -### Version - -- [ ] Release tag: -- [ ] Latest commit on `master` -- [ ] Fork: -- [ ] Commit: - -## Environment - -- OS: -- OS version: -- Architecture: - -## Description - -### Expected behavior - - - -### Actual behavior - - - -### Steps to reproduce - -1. -2. -3. - -### Logs - -If this is a CLI or Docker issue, run with debug logs and paste output. - -```text - -``` diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..b51dabf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,103 @@ +name: Bug report +description: Create a report to help Cameradar improve +labels: + - needs-triage +body: + - type: markdown + attributes: + value: | + Please make sure your problem is not already addressed in another issue. + - type: textarea + id: description + attributes: + label: Description + description: Please give a clear and concise description of the bug. + validations: + required: true + - type: textarea + id: version + attributes: + label: Cameradar version + description: Output of `cameradar version` + render: bash + placeholder: | + Version: v6.0.2-SNAPSHOT-c11e321 + Commit: c11e3217ea0b1ea9e45d0da4c072e07775bde68c + Build date: 2026-02-03T10:02:30Z + Nmap: 7.94SVN + validations: + required: true + - type: dropdown + id: env + attributes: + label: Environment + description: How do you run cameradar? + options: + - `ullaakut/cameradar` docker image + - Precompiled binary from GitHub releases + - Custom docker image + - Custom binary build + default: 0 + validations: + required: true + - type: textarea + id: os + attributes: + label: Operating system + description: Operating system where you run cameradar. + render: bash + placeholder: | + - OS: + - OS version: + - Architecture: + validations: + required: false + - type: textarea + id: cmd + attributes: + label: Command + description: The command that you ran and all of its arguments. Make sure to redact any sensitive information. Make sure to run your command in debug mode. + placeholder: | + E.g. `docker run --net=host -it ullaakut/cameradar -t localhost --debug` + validations: + required: true + - type: textarea + id: output + attributes: + label: Output logs + description: Output of the command you ran, including any error messages. Make sure to redact any sensitive information. + placeholder: | + 2026-02-03T09:33:24Z [INFO] Startup: Running cameradar version 6.0.2-SNAPSHOT-75bf524, commit 75bf524 + 2026-02-03T09:33:24Z [INFO] Startup: targets: localhost + 2026-02-03T09:33:24Z [INFO] Startup: ports: 554, 5554, 8554, http + ... + Accessible streams: 1 + • 127.0.0.1:8554 (GStreamer rtspd) + Authentication: digest + Routes: live.sdp + Credentials: admin:12345 + Availability: yes + RTSP URL: rtsp://admin:12345@127.0.0.1:8554/live.sdp + Admin panel: http://127.0.0.1/ + - type: textarea + id: expected + attributes: + label: Expected behavior + description: What is the expected behavior? + placeholder: | + E.g. "Cameradar should have been able to find the camera's RTSP stream using the provided credentials." + - type: textarea + id: additional + attributes: + label: Additional Info + description: Additional info you want to provide such as system info, target info, network conditions etc. + validations: + required: false + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Ullaakut/cameradar/blob/main/CODE_OF_CONDUCT.md). + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..b5d216d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Cameradar Community discussion board + url: https://github.com/Ullaakut/cameradar/discussions + about: Please ask and answer questions here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..fb38be5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,31 @@ +name: Feature request +description: Propose a feature or enhancement to help Cameradar improve +labels: + - needs-triage +body: + - type: markdown + attributes: + value: | + Please make sure your request is not already proposed in another issue. + - type: textarea + id: description + attributes: + label: Description + description: Please give a clear and concise description of the feature request. + validations: + required: true + - type: textarea + id: additional + attributes: + label: Additional Info + description: Additional info you want to provide. + validations: + required: false + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Ullaakut/cameradar/blob/main/CODE_OF_CONDUCT.md). + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..56c702a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +`contact+cameradar@glaulabs.com`. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. \ No newline at end of file diff --git a/cmd/cameradar/main.go b/cmd/cameradar/main.go index 0316c23..b7ec571 100644 --- a/cmd/cameradar/main.go +++ b/cmd/cameradar/main.go @@ -121,11 +121,25 @@ func realMain() (code int) { } }() + scanCommand := &cli.Command{ + Name: "scan", + Usage: "Scan targets for RTSP streams", + Flags: flags, + Action: runCameradar, + } + app := &cli.Command{ - Name: "Cameradar", - Version: version, - Flags: flags, - Action: runCameradar, + Name: "Cameradar", + Version: version, + DefaultCommand: scanCommand.Name, + Commands: []*cli.Command{ + scanCommand, + { + Name: "version", + Usage: "Print version information", + Action: printVersion, + }, + }, } ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) diff --git a/cmd/cameradar/version.go b/cmd/cameradar/version.go new file mode 100644 index 0000000..dba6de3 --- /dev/null +++ b/cmd/cameradar/version.go @@ -0,0 +1,49 @@ +package main + +import ( + "context" + "fmt" + "os" + "os/exec" + "strings" + + "github.com/Ullaakut/cameradar/v6/internal/ui" + "github.com/urfave/cli/v3" +) + +func printVersion(ctx context.Context, _ *cli.Command) error { + buildInfo := ui.BuildInfo{Version: version, Commit: commit, Date: date} + nmapVersion := getNmapVersion(ctx) + _, err := fmt.Fprintf( + os.Stdout, + "Version:\t%s\nCommit:\t\t%s\nBuild date:\t%s\nNmap:\t\t%s\n", + buildInfo.DisplayVersion(), + buildInfo.ShortCommit(), + buildInfo.Date, + nmapVersion, + ) + return err +} + +const unknownVersion = "unknown" + +func getNmapVersion(ctx context.Context) string { + output, err := exec.CommandContext(ctx, "nmap", "--version").Output() + if err != nil { + return unknownVersion + } + + lines := strings.SplitN(string(output), "\n", 2) + firstLine := strings.TrimSpace(lines[0]) + const prefix = "Nmap version " + if !strings.HasPrefix(firstLine, prefix) { + return unknownVersion + } + + versionPart := strings.TrimSpace(strings.TrimPrefix(firstLine, prefix)) + fields := strings.Fields(versionPart) + if len(fields) == 0 { + return unknownVersion + } + return fields[0] +}