Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Add user verification for admin commands #33

Merged

Conversation

galgeek
Copy link
Contributor

@galgeek galgeek commented Dec 23, 2014

hi @whimboo !

here's a patch for issue #28. I've run some quick tests on it, seems ok.
this could perhaps still be tidied up some, but it is far better than the code it replaces in the first patch.
I've added some error-checking and tweaked the adminhelp array to support all this.

@galgeek galgeek changed the title issue 28: adding user verification per admin command issue 28: adding user verification per admin command (#28) Dec 24, 2014
":addHelper" : ":addHelper <nickname> as a Test Day helper",
":next" : ":next <start as YYYY-MM-DDThh:mmZ> <end as YYYY-MM-DDThh:mmZ> <etherpad> <topic> as next Test Day",
":stats" : ":stats display Test Day stats",
":stop" : ":stop Test Day early"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we need all those changes. Especially not on this PR, which should only cover additional admin checks. Please revert that and if really necessary file a new issue and PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, lets forget that. I see now why it was used for.

@galgeek galgeek force-pushed the i28-add-admin-verification-per-command branch from ad520f8 to a80b734 Compare December 30, 2014 02:57
galgeek added a commit to galgeek/testdaybot that referenced this pull request Dec 30, 2014
@galgeek galgeek changed the title issue 28: adding user verification per admin command (#28) Add user verification for admin commands (#33) Dec 30, 2014
@galgeek galgeek changed the title Add user verification for admin commands (#33) Add user verification for admin commands Dec 30, 2014
@galgeek
Copy link
Contributor Author

galgeek commented Dec 30, 2014

hi @whimboo !

thanks for your feedback. the updated commit addresses it, except as I've noted in response to your line notes above.

}
break;
case ":addAdmin":
if (cmdLen >= 2){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now lets compare to exactly 2. We do not handle anything else than the first argument to the command. The same applies to the other commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

My logic was that Javascript functions generally ignore extra parameters, and we do report what we've done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we pass in only a single argument, but my point is that the user has to make use of the correct command definition. We might have to do extra checks in the future, but for now that length check should be enough.

@galgeek galgeek force-pushed the i28-add-admin-verification-per-command branch from a80b734 to d224041 Compare December 30, 2014 19:31
galgeek added a commit to galgeek/testdaybot that referenced this pull request Dec 30, 2014
@galgeek
Copy link
Contributor Author

galgeek commented Dec 30, 2014

Hi @whimboo !

Thanks for your feedback. I've updated this pull request. I've also responded to a couple of your line notes above.

Maybe this is ready to be merged?

@galgeek
Copy link
Contributor Author

galgeek commented Dec 31, 2014

hi @whimboo !

I've added another commit, adding verification for arguments to :addAdmin and :addHelper, checking first that the to be added is signed on to the channel before verifying with client.whois. This code tests fine, but I'm sure it could be condensed...

I'm curious to know whether you're comfortable with these limits on an added nick.

@@ -126,72 +127,95 @@ client.addListener('message', function(from, to, message){

client.addListener('pm', function(from, message){ // private messages to bot
checkTestDay();
if (message.search(':adminhelp') === 0){
var command = message.split(" ");
if (command[0] in adminhelp){ // admin command
if (testDayAdmins.indexOf(from) >= 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets negate this check and return early so that we can reduce the nested if/else conditions.

@galgeek galgeek force-pushed the i28-add-admin-verification-per-command branch from 5e7debf to e7b943f Compare January 6, 2015 07:43
@galgeek
Copy link
Contributor Author

galgeek commented Jan 6, 2015

hi @whimboo

I've restructured this listener to decrease nesting.

I've also backed out the checks on arguments to :addAdmin and :addHelper. Since we already check for logged on user of a registered nick and membership in the admin list before we run any admin command, it doesn't add much security to check these arguments, too. Moreover, it's not at all clear how we might verify a nick that's not currently signed in; that should probably be a separate issue.

thank you for your feedback!

@galgeek
Copy link
Contributor Author

galgeek commented Jan 6, 2015

hi @whimboo

I see some possibilities, in /help ... output from the Mozilla IRC server, for doing additional validation of arguments to :addAdmin/:addHelper, in particular, the /check command available to operators (though apparently not to all channel operators, so I can't test them with op on the #testdaybotTest channel), and there may be others. Maybe you know more?

I do think this should be a separate issue.

@whimboo
Copy link
Contributor

whimboo commented Jan 6, 2015

Moreover, it's not at all clear how we might verify a nick that's not currently signed in; that should probably be a separate issue.

Right now I think we should not allow the action and abort it. Only identified users should be able to get added.

@whimboo
Copy link
Contributor

whimboo commented Jan 6, 2015

Also not exactly sure what you mean with the /help output. Maybe you can clarify?

@galgeek
Copy link
Contributor Author

galgeek commented Jan 6, 2015

Hi @whimboo

Mozilla's IRC server has an operator command, /check <nick> that looks like it might provide info on nicks that are not currently signed in, or not using our channel. If we want to allow :addAdmin to add a user with a registered nick who is not currently signed in, we need an alternative to node-irc's Client.whois to check, since that works only for signed in users.

@galgeek galgeek force-pushed the i28-add-admin-verification-per-command branch from e7b943f to 340f07b Compare January 6, 2015 21:06
galgeek added a commit to galgeek/testdaybot that referenced this pull request Jan 6, 2015
@galgeek
Copy link
Contributor Author

galgeek commented Jan 6, 2015

Hi @whimboo
I’ve rebased on updated master, and removed one more level of nesting.
I used just git rebase master but still had to push +branch.
Thank you again for all your feedback and help!

@whimboo
Copy link
Contributor

whimboo commented Jan 7, 2015

Hm, /check is really for operators of the IRC network. So no-one of us will have access to it.


client.whois(from, function(whoisinfo){
if (!(whoisinfo.accountinfo && whoisinfo.accountinfo.search('is logged in as') >= 0)){
client.say(from, "Sorry! You're not logged in with a registered nick.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also return early here.

nit: something I have seen a lot and which might be helpful to you... opening { brackets will also get a blank before. You might want to have a look at our general Mozilla coding styles: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style

@galgeek galgeek force-pushed the i28-add-admin-verification-per-command branch from 340f07b to 18f5b1d Compare January 7, 2015 22:11
@whimboo
Copy link
Contributor

whimboo commented Jan 7, 2015

This looks fine to me. I will get it merged in a minute. Thanks Barbara!

@whimboo whimboo merged commit 18f5b1d into mozilla:master Jan 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants