edsu / anon

tweet about anonymous Wikipedia edits from particular IP address ranges
Creative Commons Zero v1.0 Universal
975 stars 152 forks source link

Separate IP Ranges from Bot Config #93

Closed chrismeller closed 10 years ago

chrismeller commented 10 years ago

Now that individual IP ranges are being contributed back, it's gotten more difficult to maintain your own bot config.

With IP ranges and the rest of your bot's config in the same file you either have to maintain separate configs (one for actual use, one for contributing your IP ranges) or manually wipe out your Twitter credentials every time you want to push a new update (and hope you don't accidentally commit the whole thing because you're drunk not paying attention).

I suggest an easy backwards-compatible change: In your main config file if the "ranges" key appears to be an object, we treat it as a list of ranges (the current behavior). If it is a string, it is considered a separate config file containing the ranges object that gets loaded instead.

edsu commented 10 years ago

Thanks for this. I wonder if @ruebot was right to want to have the anon repository simply reference the github repositories (in the README.md) where bot owners could manage their own configs.

This way the pull request would come to the bot owner instead of me, and it would be up to the bot owner to decide whether or not to merge/manage the changes.

Does this sound like it could work?

Another alternative would be to make you an admin on the anon repository and assign the pull requests to you when they come in.

I'd like to keep the config simple.

ruebot commented 10 years ago

I do really like @chrismeller's idea of changing ranges to a string. A simple solution what I've been trying to figure out in my own head for the last two weeks. My inefficient copy-and-paste method for taking the contributions from gccaedits-ip-address-ranges to the actual config file would be done away with. :smile:

But, the community aspect of this is a little tricky, and depends on what we're going for exactly. Centralized or distributed? Or, something else?

I've been maintaining a separate repo for just the IP ranges. This is for transparency, and allowing folks to contribute. It seems to be working. At least it works better than the original Gist file I had setup :wink:

I'd like to believe that by having the repo for @gccaedits, it allows folks to feel apart of it, and have some sort of ownership. I'm not sure how other bots are handling this, and to be honest, it doesn't really matter after awhile. Sooner or later a bot will have all the available addresses. Is this just a crowd-sourcing stop-gap?

Anyway, I guess we have to decide if we want anon to be a centralized repo, and allow the community that was formed around the entire project to congregate there? Or, allow each bot owner to maintain their community contributions however they or their communities decides is best for their bot.

chrismeller commented 10 years ago

Dealing with the pull requests wasn't the problem I was trying to solve. I was trying to make it easier on the individual bot owners to contribute the IP ranges they are using back to the community and keep them accurate as they make updates.

I don't think the change I proposed would make the configuration any more complex. For people who are fine with having their IP ranges embedded in the same config with their Twitter credentials there would be no change. For people who people who would like the keep their public and private configs separate (a fairly standard practice), they could.

For example:

In config.json:

{
  "nick": "yourIrcNickHere",
  "accounts": [
    {
      "consumer_key": "",
      "consumer_secret": "",
      "access_token": "",
      "access_token_secret": "",
      "template": "{{page}} Wikipedia article edited anonymously by {{name}} {{&url}}",
      "ranges": "conf/congressedits.json",
      "whitelist": {
        "English Wikipedia": {
          "Sherrod Brown": true,
          "Maria Cantwell": true,
          "Ben Cardin": true,
          "Tom Carper": true
        }
      }
    }
  ]
}

And in conf/congressedits.json:

{
  "US House of Representatives": [
    "143.231.0.0/16",
    "137.18.0.0/16",
    "143.228.0.0/16",
    "74.119.128.0/16",
    ["12.185.56.0", "12.185.56.7"],
    ["12.147.170.144", "12.147.170.159"]
  ],
  "US Senate": [
    "156.33.0.0/16"
  ]
}

This allows you to fork the edsu/anon project, add your IP ranges to your respective file in the conf directory, and then explicitly ignore your main config.json file so you never accidentally commit your Twitter OAuth credentials for the world to see simply because you staged and committed all your changes by mistake.

ruebot commented 10 years ago

:+1:

chrismeller commented 10 years ago

I don't think how or if the IP ranges are consolidated is really at issue.

Ignoring the idea of a central repository entirely, if I want to publish my fork on Github so that other people can contribute to the ranges, I still have a problem of manually maintaining a config file that is safe to commit and show to the world (one without Twitter credentials) and maintaining the exact same config file that I actually use (one with Twitter credentials).

I'm a developer. I'm busy. I'm lazy. This stupid bot that doesn't make me any money is broken again, so I have to update the IP range. No problem, I did my research and found the new range and updated the config and started the bot again. If I can't just immediately commit a single file and push it for the world to use, eventually it's probably not going to get done.

Manually copying and pasting (I'm using Vim over SSH, so this is naturally 10x more difficult than it probably should be) between two files, assuming I got the syntax right (because it's not the config I start my bot with, I can't test), and then making sure I'm not so rushed that I commit the wrong file makes a labor of love a lot more labor-intensive than it needs to be.

edsu commented 10 years ago

@chrismeller can you give the external-ranges branch a try and see if it works as you expect?

chrismeller commented 10 years ago

@edsu It appears to.

wdenton commented 10 years ago

This is great---will be very useful elsewhere.

edsu commented 10 years ago

Ok, I've updated all the configs, hopefully that's not too disruptive ... I will merge now.