Skip to content

Developer Guide

Josh Carlson edited this page Nov 27, 2025 · 45 revisions

Summary

Contributions to IP-2-CloudResource are always appreciated! The only requirement is that any contributions follow the guidelines outlined on this page. If not, it's highly likely your contribution will be turned down, or at least required to be fixed first.

Application Overview

IP-2-CloudResource (or IP2CR for short) is an application used to connect a given IP address with its associated cloud resource. The user can provide an IP and IP2CR will enumerate the resources in their cloud account and search through for a matching resource.

The memory and file size footprint is kept small to limit the resource impact of running this software, especially if running at a large scale.

Mission Statement

IP2CR's main tenants are speed and ease-of-use; optimally, a user should be able to correlate an IP address to a cloud resource in an equal, if not less, amount of time than querying a traditional cloud inventory database. Everything that can be reasonably done to support users in doing that should be done.

Planning

Workflow

IP2CR works in a scrum methodology. Work is divided into sprints; these sprints are version-bound, not time-bound as the former seems to fit the development workflow better. Each sprint is created as a milestone, and all issues that are in scope for that version are added to the milestone.

For large efforts, it's suggested to create an "epic" issue and link the individual work units ("stories") in the summary. This helps better organize features and other large changes, and gives a good summary for feature branches to be linked to.

Submitting New Issues

Feel free to submit a new issue if you believe you've found a bug in IP2CR, would like to suggest a useful feature, etc. Please make sure the respective templates are used, if applicable.

Coding Standards

Branch Standards

Active Branches

IP2CR typically has at least two active branches at any given time: the default branch (main) and the release branch (release-{NEW_VERSION}).

Release Branches

Each patch-level version (e.g. x.y.z) has its own branch. For example, version 1.0.0 can be viewed by switching to the release-v1.0.0 branch. These branches are not deletable, and are intended to be immutable after being merged to the main branch and released.

Naming Conventions

All release branches must follow the aforementioned syntax, feature branches must be prefixed with feature-XX_, and issue branches prefixed with issue-XX_, where XX is the issue number.

Examples:

  • release-v0.0.1
  • feature-123_implement-ip-fuzzing
  • issue-789_fix-syntax-error-with-ip-cli-flag

Directory Structure

The general directory structure of IP2CR is outlined below, and should be followed where possible:

  • All packages are in the root directory
  • Within the root directory, there are several child directories, some of which are standalone packages, while some contain specific groups of packages, including:
    • plugin/: all packages related to cloud service provider plugins, e.g. code for searching/enumerating AWS CloudFront
    • svc/: any standalone, major feature should have its own package within this directory, e.g. IP Fuzzing
    • utils/: any general utility packages, e.g. DNS lookup functionality

Preferred Coding Logic

Text Normalization

When you're fetching/ingesting external data that contains strings that are used as keys or references, that data should be normalized as quickly after ingestion as possible.

Normalization Rules

The following logic should be taken into account when normalizing text (NOTE: not all may apply for all data sources):

Element Preference Alternative
Encoding ASCII UTF-8 if required for feature
Character Case lowercase N/A

Example

A good example of this standard is the normalization of service names from AWS's service IP API.

COMING SOON

Style Requirements

Standards in Use

Comments

IP2CR takes a self-documenting code approach to contextual comments. As such, comments should be kept to a minimum. A good way to think about it that comments should be the exception, not the rule.

Testing Requirements

  • All PRs must be submitted with appropriate unit tests, and all new code must have unit tests written for it where possible
  • To test AWS Organizations, you can create two free AWS accounts, set them up within AWS Organizations with a parent-child relationship, and follow the setup guide.
  • Codacy calculates the test coverage of the code being modified as the diff coverage; this value should be available via the respective status check or inline PR decoration

Commits

Commit Messages

General Format

The general format of commit messages should be:

<KEYWORD>: <SUMMARY>

<DETAILS>

Related Issues:
- Fixes #XXX
- Required By #YYY

KEYWORD is only required if applicable.

Keywords

One requirement that is in place for commit messages is the usage of keywords in the summary, where applicable. Currently the following keywords are required:

  • deploy
    • Commit is for deploy-related purposes, e.g. bumping the application version
  • minor
    • This change is a minor change that is unworthy of being added to the changelog, e.g. fixing a type in the README
  • test
    • The code change is to add a test only; no application code is changed, and as such, shouldn't be included in the changelog

These are in place to keep the release change logs are clean. Note that this is not an exhaustive list; other keywords that may be applicable may be used too, e.g. feature.

Length

IP2CR generally tries to follow the 50/72 rule for commit messages: first line is a summary of < 50 characters, then a blank line, then additional details, with each line curtailed at < 72 characters.

Be aware that this is not a hard requirement; if you need more characters to write a good commit message, use them!

Example

Feature: Add Support For S3 Public IPs

Add plugin to support finding public IPs associated with S3 buckets.

Related Issues:
- Fixes #123
- Required By #456

Signed Commits

It's highly recommended to sign your commits if you plan on contributing to IP2CR. This will likely be required as part of branch protection rules in the future.

Pull Requests

Naming Conventions

For PRs, the same keywords that are required with commit message naming conventions must be included in the PR summary. This is to ensure a clean change log is auto-generated by GoReleaser during deploy.

Submitting Third-Party PRs

If you are looking to contribute to IP2CR and have your code ready to merge, submit a new PR for consideration, making sure to follow the requirements and instructions below.

Branch Protection and Status Checks

Both main and release branches require PRs and cannot be committed to directly.

  • PRs merging into release-* branches are required to pass the status checks for:
    • Codacy
    • Successful builds for stable version of Go running on the latest version of Ubuntu
  • PRs merging into main branches are required to pass the status checks for:
    • CodeQL (SAST)
    • Codacy (Code Coverage and SAST)
    • Successful builds for both stable and oldstable versions of Go on all supported OS's

PR Submission Checklist

When creating a PR, it's recommended to follow this checklist:

  • Checkout the current dev release branch and create a new branch for your work according to branch naming conventions
  • Write your code and make any other changes, ensuring they confirm to style and testing requirements
  • Commit and push your changes, using instructions listed in the commits section
  • Create a new PR and configure it to merge your branch into the current dev release branch
    • Ensure the PR template is filled out as completely as possible

If all status checks complete successfully after submitting, a maintainer will review the PR and merge if accepted. If not, review the causes for failures and resolve them.

Releases

Versioning

Semantic Versioning is in use.

Tagging

All releases are tagged in the main branch using the version as a value, e.g. v0.0.1. These types of tags are only allowed to be pushed by approved maintainers as they will trigger an automatic release.

SLSA

With Issue #344, the SLSA framework was implemented with Level 3 specifications in order to improve and harden build pipeline security. It's recommended to read the docs, but in a nutshell, this means that a metadata file is generated that allows all artifact builds will be cryptographically verifiable.

How Is The Provenance Generated?

The provenance file is generated post-build using the slsa-github-generator Github Actions plugin. This job is run as part of the release build workflow.

How Is The Provenance Verified?

You can use the slsa-verifier tool. The docs outline all of the available options, but you can use the bash one-liner below to verify a given release. The one-liner assumes the slsa-verifier tool has been installed and is in the current path:

read -p "VERSION (e.g. v1.0.0): " APP_VER && \
  wget -q https://github.com/magneticstain/ip-2-cloudresource/releases/download/${APP_VER}/ip-2-cloudresource_Linux_x86_64_${APP_VER}.tar.gz -O /tmp/ip-2-cloudresource.tar.gz && \
  wget -q https://github.com/magneticstain/ip-2-cloudresource/releases/download/${APP_VER}/multiple.intoto.jsonl -O /tmp/ip2cr_slsa_provenance.intoto.jsonl && \
  slsa-verifier verify-artifact /tmp/ip-2-cloudresource.tar.gz \
  --provenance-path /tmp/ip2cr_slsa_provenance.intoto.jsonl \
  --source-uri github.com/magneticstain/ip-2-cloudresource \
  --source-tag ${APP_VER}

You should see a PASS or FAIL message displayed once verification is complete.

Performing a Release

Prep Work

Before deploying a release of IP2CR, there's some prep work that must be done first.

Tool Review

Review and fix/triage any remaining findings within developer tools used with IP2CR, including Rollbar, and Codacy.

App Metadata

The application metadata must be updated for each release, if it hasn't been updated already. All of these constants should be in app.go.

  1. Update the APP_VER value to the new version number (e.g. v1.0.0)
  2. Update the APP_ENV value to production

Docs

Supported Versions

If needed, update the "Supported Versions" section of the security policy to reflect the new version

Version in "Commits Since..." Badge

In the README, there is a badge that indicates the number of commits made since a given release. Since we're making a new release, we're need to update that with the version number of the new release. To do that, you can update the version number at the end of the URL.

An example of moving from v1.0.0:

![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/magneticstain/ip-2-cloudresource/v1.0.0)

to v1.0.1:

![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/magneticstain/ip-2-cloudresource/v1.0.1)

Here is a code reference to it in the README. And this is how it's rendered with the version set to 1.0.0:

GitHub commits since latest release (by SemVer including pre-releases)

Dependency Update

Next, all DependencyBot Pull Requests to update application dependencies should be merged, tested, and closed to ensure that IP2CR has the most up-to-date dependencies included with it upon release.

Deploy Release

Initiating a release of IP2CR is relatively simple: we just add a version tag and push. Then CI/CD takes care of the rest.

You can use this (ZSH) on-liner and enter the version number to easily execute the needed git commands (uses signed tags):

vared -p "VERSION (e.g. v1.0.0): " -c APP_VER && \
  git checkout main && \
  git pull && \
  git checkout -b "release-${APP_VER}" && \
  git tag -s -m "Release of ${APP_VER}" "${APP_VER}" && \
  git push --set-upstream origin "release-${APP_VER}" && \
  git push origin --tags && \
  git checkout main && \
  git pull

Post-Release

Once the release has completed successfully, there are a few tasks left in order to prepare for the next release.

  1. Close the milestone for the current release and create a new one for the next release, if applicable
  2. Archive all Issues in the "Done" column of the IP2CR project board
  3. Update the APP_ENV value back to development
  4. Update the APP_VER value to the next version, if known
⌂ 换网址