From de916a376fa20a52a25e9194fa3cce72cf94f4f1 Mon Sep 17 00:00:00 2001 From: Josh Carlson <837837+magneticstain@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:04:41 -0500 Subject: [PATCH] Minor: Sync Release v1.4.6 w v2.0.0 Branch (#386) * Bump to trigger container release (#373) * Update version * Update version in "Commits since" badge * Deploy: Release v1.4.2 (#375) * Minor: Update app versions * Switch to goreleaser for container image deploy (#374) * Remove current container deploy workflow config * Update goreleaser config and relase workflow for docker release support * Add new Dockerfile for releases (#376) This is to be in line with goreleaser reqs * Migrate from docker/login-action to custom script for registry auth Required as docker-login-action doesn't support multi-registry authentication. * Deploy: Release v1.4.5 (#377) * Minor: Update versions * Revert migration from login-action to custom I misunderstood the github action logs :( * Update Job Permissions to Remove Content:Read Permission This was overriding the globally-set Content:Write permission. This caused the GHAW for releases to fail to create a release * Issue 383 add service to user output (#384) * Add `CloudSvc` as a attribute of `Resource()` * Add CloudSvc Value to Output For Found Resource * Set CloudSvc in All Supported Resource Plugins * Minor: Fix typo in found resource user output * Minor: update app version --- README.md | 2 +- main.go | 5 ++--- plugin/cloudfront/cloudfront.go | 1 + plugin/ec2/ec2.go | 1 + plugin/elb/elb.go | 1 + plugin/elb/elb_classic.go | 1 + resource/resource.go | 2 +- 7 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e8dcd47..c67437e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Codacy Badge - Quality](https://app.codacy.com/project/badge/Grade/5137ec7cf2d14a9c9fc3eac1cd37e0d3)](https://app.codacy.com/gh/magneticstain/ip-2-cloudresource/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Codacy Badge - Coverage](https://app.codacy.com/project/badge/Coverage/5137ec7cf2d14a9c9fc3eac1cd37e0d3)](https://app.codacy.com/gh/magneticstain/ip-2-cloudresource/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) -![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/magneticstain/ip-2-cloudresource/v1.4.5) +![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/magneticstain/ip-2-cloudresource/v1.4.6) ![GitHub issues](https://img.shields.io/github/issues/magneticstain/ip-2-cloudresource) ![GitHub pull requests](https://img.shields.io/github/issues-pr/magneticstain/ip-2-cloudresource) ![GitHub all releases](https://img.shields.io/github/downloads/magneticstain/ip-2-cloudresource/total) diff --git a/main.go b/main.go index 7cc13ea..f040631 100644 --- a/main.go +++ b/main.go @@ -17,8 +17,7 @@ import ( "github.com/magneticstain/ip-2-cloudresource/utils" ) -const APP_ENV = "development" -const APP_VER = "v1.4.5" +const APP_VER = "v1.4.6" func outputResults(matchedResource resource.Resource, networkMapping bool, silent bool, jsonOutput bool) { acctAliasFmted := strings.Join(matchedResource.AccountAliases, ", ") @@ -32,7 +31,7 @@ func outputResults(matchedResource resource.Resource, networkMapping bool, silen acctStr = fmt.Sprintf("account [ %s ( %s ) ]", matchedResource.AccountID, acctAliasFmted) } - log.Info("resource found -> [ ", matchedResource.RID, " ] in ", acctStr) + log.Info("resource found -> [ ", matchedResource.RID, " ] within ", matchedResource.CloudSvc, " service running in ", acctStr) if networkMapping { var networkMapGraph string diff --git a/plugin/cloudfront/cloudfront.go b/plugin/cloudfront/cloudfront.go index 9dc1430..fc1b069 100644 --- a/plugin/cloudfront/cloudfront.go +++ b/plugin/cloudfront/cloudfront.go @@ -82,6 +82,7 @@ func (cfp CloudfrontPlugin) SearchResources(tgtIP string) (generalResource.Resou for _, ipAddr := range cfIPAddrs { if ipAddr.String() == tgtIP { matchingResource.RID = *cfDistro.ARN + matchingResource.CloudSvc = "cloudfront" if cfp.NetworkMapping { matchingResource.NetworkMap = append(matchingResource.NetworkMap, *cfDistro.DomainName, *cfDistro.Id) diff --git a/plugin/ec2/ec2.go b/plugin/ec2/ec2.go index da22758..77a9fee 100644 --- a/plugin/ec2/ec2.go +++ b/plugin/ec2/ec2.go @@ -60,6 +60,7 @@ func (ec2p EC2Plugin) SearchResources(tgtIP string) (generalResource.Resource, e if publicIPv4Addr == tgtIP || IPv6Addr == tgtIP { matchingResource.RID = *instance.InstanceId // for some reason, the EC2 Instance object doesn't contain the ARN of the instance :/ + matchingResource.CloudSvc = "ec2" if ec2p.NetworkMapping { matchingResource.NetworkMap = append(matchingResource.NetworkMap, *instance.VpcId, *instance.SubnetId, *instance.InstanceId) diff --git a/plugin/elb/elb.go b/plugin/elb/elb.go index b17ce26..3efa1d6 100644 --- a/plugin/elb/elb.go +++ b/plugin/elb/elb.go @@ -124,6 +124,7 @@ func (elbp ELBPlugin) SearchResources(tgtIP string) (generalResource.Resource, e for _, ipAddr := range elbIPAddrs { if ipAddr.String() == tgtIP { matchingResource.RID = *elb.LoadBalancerArn + matchingResource.CloudSvc = "elbv2" if elbp.NetworkMapping { matchingResource.NetworkMap = append(matchingResource.NetworkMap, *elb.DNSName, *elb.CanonicalHostedZoneId) diff --git a/plugin/elb/elb_classic.go b/plugin/elb/elb_classic.go index d2d922f..b58b9f5 100644 --- a/plugin/elb/elb_classic.go +++ b/plugin/elb/elb_classic.go @@ -55,6 +55,7 @@ func (elbv1p ELBv1Plugin) SearchResources(tgtIP string) (generalResource.Resourc for _, ipAddr := range elbIPAddrs { if ipAddr.String() == tgtIP { matchingResource.RID = *elb.LoadBalancerName + matchingResource.CloudSvc = "elbv1" if elbv1p.NetworkMapping { matchingResource.NetworkMap = append(matchingResource.NetworkMap, *elb.DNSName, *elb.CanonicalHostedZoneNameID, *elb.VPCId, utils.FormatStrSliceAsCSV(elb.AvailabilityZones), utils.FormatStrSliceAsCSV(elb.Subnets)) diff --git a/resource/resource.go b/resource/resource.go index 5d23205..a9ed371 100644 --- a/resource/resource.go +++ b/resource/resource.go @@ -1,6 +1,6 @@ package resource type Resource struct { - RID, AccountID string + RID, AccountID, CloudSvc string AccountAliases, NetworkMap []string }