Git Product home page Git Product logo

ip-whitelister's People

Contributors

alec-pinson avatar jnickson avatar joshua-hancox avatar luigibk avatar pyrxm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ip-whitelister's Issues

`go vet` returns `bad syntax for struct tag pair`

It appears there have been a couple of typos in config.go and user.go when go vet is run.

➜  ip-whitelister git:(main) go version
go version go1.17.13 darwin/amd64
➜  ip-whitelister git:(main) go vet
# github.com/alec-pinson/ip-whitelister
./config.go:26:2: struct field tag `yaml":ttl"` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair
./user.go:28:2: struct field tag `json:"objectId` not compatible with reflect.StructTag.Get: bad syntax for struct tag value
➜  ip-whitelister git:(main)

BUG: log reports error and says updated even when resource hasnt been updated

2022/01/06 15:23:50 azure.AzureFrontDoor.update():frontdoor.PoliciesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="Conflict" Message="The requested operation cannot be executed on the entity as another operation is in progress."
2022/01/06 15:23:50 azure.AzureFrontDoor.update(): updated 'rg/policy'

`staticcheck` shows unnecessary assignment and unused function.

➜  ip-whitelister git:(main) go version
go version go1.17.13 darwin/amd64
➜  ip-whitelister git:(main) staticcheck -version
staticcheck 2022.1.3 (v0.3.3)
➜  ip-whitelister git:(main) staticcheck 
functions.go:25:9: unnecessary assignment to the blank identifier (S1005)
http.go:77:3: empty branch (SA9003)
user.go:128:16: func (*User).unwhitelist is unused (U1000)

FEATURE: allow configurable 'attempt new whitelisting' time

Whitelist TTL = 24 in this example

Current process

  1. Request whitelist
  2. 'Whitelist complete'
  3. Whitelist expires 24 hours later
  4. Request whitelist again 10 minutes later... fail
  5. Whitelist expires 24 hours later
  6. Request whitelist again 24 hours later... success

A solution to this (as we don't want to allow API spam) would be to allow each user to request a whitelist maybe once a minute or so instead.

Proposed process

  1. Request whitelist
  2. Whitelist complete
  3. Whitelist expires 24 hours later
  4. Request whitelist again 10 seconds later... fail
  5. Request whitelist again 1 minute later... success
  6. Whitelist expires 24 hours later

BUG: App crashed when trying to update FrontDoor

2 replicas were running at the time

frontdoor.PoliciesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="Conflict" Message="The requested operation cannot be executed on the entity as another operation is in progress."
panic: runtime error: invalid memory address or nil pointer dereference

issue: ip-whitelister removes tags from Azure Front Door WAF policy on start

Problem

If you add tags to your Azure Front Door WAF policy then restart ip-whitelister, the tags will be removed.

How to recreate

  1. Add some arbitary tags to terraform/frontdoor.tf, example diff below:

    diff --git a/terraform/frontdoor.tf b/terraform/frontdoor.tf
    index 1fb3315..4c61e75 100644
    --- a/terraform/frontdoor.tf
    +++ b/terraform/frontdoor.tf
    @@ -12,6 +12,11 @@ resource "azurerm_frontdoor_firewall_policy" "this" {
         https://xyz.com/ip-whitelister
       */
       lifecycle { ignore_changes = [custom_rule, managed_rule] }
    +
    +  tags = {
    +    name       = var.name
    +    created-by = "terraform"
    +  }
     }
    
     output "azure_frontdoor_policy" {
  2. Build the infra in ./terraform

  3. Check the tags on the Azure Front Door WAF policy exist in Azure Portal

  4. Configure the config file ./config/config.yaml as per the Terraform and service principal (I also did rm ./config/resources/*.yaml for testing).

  5. Run go build

  6. Run ./ip-whitelister

  7. Re-check the tags on the Azure Front Door WAF policy exist in Azure Portal - they will have been removed.

FEATURE: Require specific groups for different resources

E.g. to be whitelisted against the 'app_50_keyvault' you must be part of the 'app_50' ad group.

Config would look something like this

resources:
  - cloud: azure
    type: storageaccount
    subscription_id: notreal-not-real-not-notreal
    resource_group: notreal-rg
    name: app50storage
    group:
      - admins_group
      - app_50_group
  - cloud: azure
    type: keyvault
    subscription_id: notreal-not-real-not-notreal
    resource_group: notreal-rg
    name: app50kv
    group:
      - admins_group
      - app_50_group

If you're not part of the group, you wont be whitelisted against the resource.

FEATURE: allow static ip whitelist for each resource

e.g.

resources:
  - cloud: azure
    type: frontdoor
    subscription_id: notreal-not-real-not-notreal
    resource_group: notreal-rg
    policy_name: notrealpolicy
    ip_whitelist:
      - 85.0.0.0/24
      - 200.0.0.0/24
  - cloud: azure
    type: storageaccount
    subscription_id: notreal-not-real-not-notreal
    resource_group: notreal-rg
    name: notrealstorage
    ip_whitelist:
      - 85.0.0.0/24
      - 200.0.0.0/24

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.