New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: API allow cidr network searches of the ARP table #6378

Merged
merged 2 commits into from Apr 7, 2017

Conversation

Projects
None yet
5 participants
@murrant
Member

murrant commented Apr 7, 2017

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

  • Have you signed the Contributors agreement - please do NOT submit a pull request unless you have (signing the agreement in the same pull request is fine). Your commit message for signing the agreement must appear as per the docs.
  • Have you followed our code guidelines?

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

@mention-bot

This comment has been minimized.

Show comment
Hide comment
@mention-bot

mention-bot Apr 7, 2017

Thank you for submitting a PR @murrant! We have found the following @laf, @nerdalertdk and @adaniels21487 based on the history of these files to review this PR.

Thank you for submitting a PR @murrant! We have found the following @laf, @nerdalertdk and @adaniels21487 based on the history of these files to review this PR.

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Apr 7, 2017

Member

It doesn't actually matter but you could allow 1.2.3.4/24 in the api route still, you can do optional params in the route to do this.

Member

laf commented Apr 7, 2017

It doesn't actually matter but you could allow 1.2.3.4/24 in the api route still, you can do optional params in the route to do this.

@LibreNMS-CI

This comment has been minimized.

Show comment
Hide comment
@murrant

This comment has been minimized.

Show comment
Hide comment
@murrant

murrant Apr 7, 2017

Member

Not sure how to do that with Slim, feel free to enlighten me :)

Laravel allows you to do:

Route::get('/{network?}', 'IPDataController@show')->where('network', '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|[1-2]?[0-9])\b)?');

Edit: turns out slim is pretty similar:

$app->get('/arp/:ip', 'authToken', 'list_arp')->name('list_arp')->conditions(array('ip' => '[^?]+'));
Member

murrant commented Apr 7, 2017

Not sure how to do that with Slim, feel free to enlighten me :)

Laravel allows you to do:

Route::get('/{network?}', 'IPDataController@show')->where('network', '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|[1-2]?[0-9])\b)?');

Edit: turns out slim is pretty similar:

$app->get('/arp/:ip', 'authToken', 'list_arp')->name('list_arp')->conditions(array('ip' => '[^?]+'));
Allow non-encoded / in request
I also noticed that all is allowed to be called without device, which the sql query does not support.
@LibreNMS-CI

This comment has been minimized.

Show comment
Hide comment
@scrutinizer-notifier

This comment has been minimized.

Show comment
Hide comment
@scrutinizer-notifier

scrutinizer-notifier Apr 7, 2017

The inspection completed: 1 updated code elements

The inspection completed: 1 updated code elements

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Apr 7, 2017

Member

I would have done $app->get('/arp/:ip(/:cidr)', 'authToken', 'list_arp')->name('list_arp') but this is fine :)

Member

laf commented Apr 7, 2017

I would have done $app->get('/arp/:ip(/:cidr)', 'authToken', 'list_arp')->name('list_arp') but this is fine :)

@laf laf merged commit 4ab3585 into librenms:master Apr 7, 2017

2 checks passed

Auto-Deploy Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@murrant murrant deleted the murrant:arp-network branch Apr 8, 2017

@lock lock bot locked as resolved and limited conversation to collaborators May 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.