Commit Graph
100 Commits
Author SHA1 Message Date
pancho horrillo 28f0ae03d5 doc: misc fixes and tweaks
* doc/README.md:
  - Fix a couple of typos.
  - Fix spacing and shell quote style (for consistency with other markdown docs
  already in the tree).
  - Fix indent with spaces not tabs in heredocs with <<- style¹.
  - Fix shell example partially inserted twice.

* doc/*.pow:
  - Fix indent with spaces not tabs in heredocs with <<- style¹.

¹: See the last paragraph in
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Here-Documents

"If the redirection operator is ‘<<-’, then all leading tab characters
are stripped from input lines and the line containing delimiter. This allows
here-documents within shell scripts to be indented in a natural fashion."
2019-10-31 18:49:48 +01:00
pancho horrillo 0639b3af50 spec: add missing empty line 2019-10-31 18:45:48 +01:00
pancho horrillo d5e9ab0f07 spec: add missing space after full-stop.
Mostly to trigger a Circle CI rebuild.
2019-10-30 17:58:05 +01:00
pancho horrillo e413ce4805 Drop now-spurious env var setting in call to behave at Circle CI config 2019-10-30 17:43:14 +01:00
pancho horrillo c3180e3e7d spec: fix incorrect default value for KAPOW_DATAAPI_URL
This caused ghost failures when running the tests.
2019-10-30 17:40:40 +01:00
pancho horrillo 275db5ef91 spec: add entry on KAPOW_USER_URL env var 2019-10-30 17:40:40 +01:00
pancho horrillo 604a6d7d4d spec: add entry on KAPOW_BOOT_TIMEOUT env var 2019-10-30 17:40:33 +01:00
pancho horrilloandHéctor Hurtado 712d26db89 Tweak Circle CI config not to run skipped tests
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-29 15:18:58 +01:00
pancho horrillo 3dd038e0aa Revert nmap examples, they need more work
Closes: #65
2019-10-28 16:46:02 +01:00
pancho horrillo 00770650a8 Rename nmap example to nmap-web
* Drop unused CSS section
2019-10-25 19:21:04 +02:00
pancho horrillo c29a17d7e4 Fix handling of arguments
Closes: #67
2019-10-25 18:54:52 +02:00
pancho horrillo 56876335b7 Add yet another Nmap example, ideal to be consumed by browser
I intend to replace the nmap-streaming.pow example with this one.
I've realized that nmap-streaming.pow is not actually a streaming example,
since Nmap won't write its output(s) until scan is finished, and hence, kapow
will serve them in one shot.

Check it out, @nilp0inter, @cr0hn.
2019-10-25 08:14:38 +02:00
pancho horrillo 2fc18b76e3 poc/examples/nmap-{streaming,callback}.pow: minor cleanup
* Update comments.
* Add Content-Type: text/xml header (nmap-streaming.pow) only.
* Wrap the Nmap output in XML comment delimiters, *after* the XML header.
* Write to /response/body (preferred) instead of /response/stream (legacy).
* Use suffix .xml for temp files.
* Move possibly noise-generating calls outside of the block
  that is sent to the /request/body.
2019-10-24 17:05:54 +02:00
pancho horrilloandCésar Gallego Rodríguez b0c16ca684 Validate url_pattern format in control API append operation
Closes: #38

Co-authored-by: César Gallego Rodríguez <cesar.gallego.next@bbva.com>
2019-10-24 14:10:58 +02:00
pancho horrillo d2c3138036 Give nmap examples some lovin'.
* Add legal headers.
* Add default values for params and forms.
* Cleanup code a bit.
* Wrap nmap output in XML comments; not legal, but perhaps better than the alternative.
2019-10-24 07:27:20 +02:00
pancho horrillo 52ae3375a4 Drop stale TODO comment
Close #42
2019-10-23 18:52:20 +02:00
pancho horrillo ae3bd76434 Leverage ioutil.ReadAll() and ioutil.ReadFile() to simplify logic
Related to: #46
2019-10-23 18:01:58 +02:00
pancho horrillo 7674725658 Drop TODO line of solved issue
Related to #46
2019-10-23 17:59:37 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 034a5ab677 Fix typo in comment
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-22 16:29:54 +02:00
pancho horrillo 5bbc341e10 Update internal/cmd/server.go
- Honour --bind, --control-bind, --data-bind
- Drop unused params (--interactive, --url, --control-url, --data-url)
- Minimize environment for running the powfile shell script
- Drop debug code

TODO: actual key and cert handling for https
2019-10-20 18:39:50 +02:00
pancho horrillo 341768ace8 internal/cmd/server.go: sort imports 2019-10-20 18:38:29 +02:00
pancho horrillo bb5843ec35 Fix lowercase ID in human-readable messages 2019-10-20 18:32:46 +02:00
pancho horrillo d31165c82f Drop trailing slash in URL to query routes
This one slipped through the tests, I think because the automagic handling of
trailing slashes by the net/http muxer.

With it, the command:

    $ kapow route list

fails with a 'Not Found'.
2019-10-20 18:20:46 +02:00
pancho horrilloandCésar Gallego b14ea93a64 Minor fixes on error handling
Co-authored-by: César Gallego <gallego.cesar@gmail.com>
2019-10-17 17:11:19 +02:00
pancho horrilloandCésar Gallego ee00a7bccc Fix param names to use the right URL
Co-authored-by: César Gallego <gallego.cesar@gmail.com>
2019-10-17 17:04:59 +02:00
pancho horrilloandCésar Gallego 4638bec5fe Gather binding vars for each server and run them
Co-authored-by: César Gallego <gallego.cesar@gmail.com>
2019-10-17 17:03:45 +02:00
pancho horrilloandCésar Gallego 81cbea4ff8 Fix method used in client.AddRoute()
Co-authored-by: César Gallego <gallego.cesar@gmail.com>
2019-10-17 16:58:38 +02:00
pancho horrillo b4f2e9ffdd Refactor tests
* Get rid of spurious model.Route{} var, by adding content
directly into model.Handler{} literal.

* Adjust spacing to adhere to the prepare-call-test test structure.
2019-10-13 08:17:16 +02:00
pancho horrillo c62a0d6a9a Sort imports intro three blocks (stdlib, non-stdlib, current prj) 2019-10-13 08:09:15 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez df5d38e94f swappableMux is now public and Append() now updates Server.Handler
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-10 20:22:09 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez b4dd6e9805 Add New() func & Update() method to internal/server/user/mux/swappableMux
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-10 19:26:17 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 463382bfb2 Add internal/server/user/mux/handlerbuilder{,_test}.go
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-10 18:16:15 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 2129c4a1f6 internal/server/model.Handler.Route is no longer a pointer
Also Spawn() now checks if entrypoint is not set

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-10 18:16:15 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez b76fb1f77e Add method ListIDs() to internal/data/Handlers
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-10 13:11:05 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez a39e0f6605 Spawner ready
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-10 11:49:58 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez d0764f07a4 First cut to spawner
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-09 18:28:33 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez fa8cc271dc Build jaillover via Makefile
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-09 16:25:04 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 273058c3ba Add testutils/jaillover to assist testing process spawning
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-09 16:17:21 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 49252a78a6 Fix misuse of gorilla/mux.Router{} use mux.NewRouter() instead
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-09 15:22:50 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 401644b65e Finish gorillize()
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-09 13:10:04 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 2cd96d5a4b Add the controversial gorillize()
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 19:39:44 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 037347dbe3 Augment safeRouteList.Append() to return a model.Route with index
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 17:53:15 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez e0dd6f5dd5 Refactor internal/server/user package structure
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 17:22:09 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 2eb32610a0 Exclude test from race condition verification
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 15:34:42 +02:00
9ad61249b3 Fix linter warning
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-08 15:33:32 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 3b405bd9f6 Add ServeHTTP() method to swappableMux struct
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 15:06:08 +02:00
pancho horrillo 0cab49f082 Simplify handling of http.Client response
As per the doc¹:

  If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close.
  ...
  On error, any Response can be ignored. A non-nil Response with a non-nil error
  only occurs when CheckRedirect fails, and even then the returned Response.Body
  is already closed.

It is thus safe to defer res.Body.Close() as soon as err has been determined to
be nil.

Also, I've dispensed with the separate variable client, since it is not used
later.

¹: https://godoc.org/net/http#Client.Do
2019-10-08 05:42:33 +02:00
pancho horrillo 7ba54b32b3 Revert to using strings for simplicity
It is safe in this case.

* gock.BodyString(body string) coerces body into a []byte
* client.SetData() eventually resolves to a call to http.Client.Do(), which
handles the string gracefully as well.
2019-10-08 05:28:29 +02:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 10586bae95 Add internal/server/user/server{,_test}.go
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-07 19:05:59 +02:00
pancho horrillo 0b056f6cf0 internal/client/{get,set}_test.go: send io.Writer() based on []byte
* internal/client/get_test.go:
  - Revert changes when setting the Body of the mock (gock).
  - Revert over-eager line splitting.

* internal/client/set_test.go:
  - Use bytes.NewReader([]byte("200")) instead of strings.NewReader("200")

Thanks to @nilp0inter for the feedback!
2019-10-06 11:34:15 +02:00
pancho horrillo f98784088d Normalize internal/client/*_test.go
* Adjust test style for easy reading, by using literals instead of vars
* Move comparison to the `bytes` domain, instead of `string`
* Simplify testing code by using bytes.Buffer directly
* More consistent naming of variables and dummies (HANDLE_{FOO,BAR,BAD})
* Consistent testing style of gock.IsDone()
* Stick to 80-column
2019-10-06 09:41:12 +02:00
pancho horrillo 6154210b3f Update PoC and features with the 204 -> 404 update
Closes #33
2019-10-04 17:24:27 +02:00
pancho horrilloandHéctor Hurtado a865ade26a Use string concatenation to compose simple expression
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-04 07:28:08 +02:00
pancho horrilloandHéctor Hurtado 57d1aabb66 internal/cmd/route.go: replace dummies with calls to client code
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-04 06:46:40 +02:00
pancho horrilloandHéctor Hurtado b9bf78abf4 Fix route_add{,_test}.go to use an io.Writer for saving the response
Also add a TODO regarding untested response payload.

Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-04 06:28:17 +02:00
pancho horrilloandHéctor Hurtado 219710bb76 Fix documentation comment
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-04 06:04:56 +02:00
pancho horrillo c65d2ac548 Don't set MatchType to json in gock for requests without body 2019-10-03 22:50:42 +02:00
pancho horrillo c01c3db4f9 Fix indentation and drop spurious whitespace 2019-10-03 22:48:21 +02:00
pancho horrillo df96d322fc Don't set Content-Type to application/json in query without body 2019-10-03 22:47:43 +02:00
pancho horrilloandHéctor Hurtado 604569c7a3 Add internal/client/route_list{,_test}.go
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 22:42:31 +02:00
pancho horrilloandHéctor Hurtado 013cd4d637 Add internal/client/route_remove{,_test}.go
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 18:22:18 +02:00
pancho horrilloandHéctor Hurtado 306889c958 Add TODO on closing the connection of the http.Client
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 16:52:55 +02:00
pancho horrilloandHéctor Hurtado ffa262b2b6 Simplify internal/client/set.go by leveraging internal/http.Request()
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 16:52:15 +02:00
pancho horrilloandHéctor Hurtado 23128026c7 Rework directory structure
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 12:05:53 +02:00
pancho horrillo 27cf52467d poc: Drop unused import 2019-09-16 10:24:11 +02:00
pancho horrillo 19bb6320b9 spec: Fix command name start -> server 2019-09-16 09:19:19 +02:00
pancho horrillo 32d0a00c43 Merge pull request #26 from BBVA/fix/style
Style fixes and minor typos.
2019-09-09 14:45:28 +02:00
pancho horrillo b4b5052149 Revert "Style fix."
This reverts commit 5c72f3a498.

Thanks to @nilp0inter for clarifying this one as well.
2019-09-09 14:40:52 +02:00
pancho horrillo 94135c6ab9 Revert "Style fix."
Thanks to @nilp0inter for pointing out that this was not Basic English.

This reverts commit 0eb51f12ac.
2019-09-09 14:30:07 +02:00
pancho horrillo 567f68b695 Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 28c16409a8 Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 84f6a89c2d Clarify expression. 2019-09-06 13:55:22 +02:00
pancho horrillo ff0f3aefc5 Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 249d0f3e9f Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 41d8f39c9a Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 5c72f3a498 Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 3a545ac7b3 Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 0eb51f12ac Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 36a61285b9 Style fix.
Note: "midst" tends to be used in more literary settings.
2019-09-06 13:55:22 +02:00
pancho horrillo b22f3a5adb Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 42403fe78c Style fix. 2019-09-06 13:55:22 +02:00
pancho horrillo 9fdd75f6d8 Fix typo. 2019-09-06 13:55:22 +02:00
pancho horrillo 479e3cb13b Fix markdown and add missing -E param to sudo. 2019-09-06 13:54:43 +02:00
pancho horrillo b577dd93d3 Fix usage of sudo to prevent issues with the environment.
Also fix a couple of typos.
2019-09-06 13:48:51 +02:00
pancho horrillo 667d081de5 Merge pull request #24 from BBVA/feature/overwrite-resource-scenario
Add scenario to the test suite where overwriting resources is checked.
2019-09-06 09:21:19 +02:00
pancho horrillo 157886c3a5 Add scenario to the test suite where overwriting resources is checked.
Thanks to @nilp0inter for providing justification for the scenario.
2019-09-05 18:57:47 +02:00
pancho horrillo 2b64e1cb92 Merge branch 'hotfix-control-access' 2019-07-05 10:40:29 +02:00
pancho horrillo 23c66f4794 Use '127.0.0.1' instead of 'localhost' to prevent IPv6 resolution errors in Docker 2019-07-04 12:22:04 +02:00
pancho horrillo fc4f4ac8cb README.rst: fix link to the spec 2019-07-01 15:59:30 +02:00
pancho horrillo 00b539b1aa README.rst: style fixes 2019-07-01 15:56:56 +02:00
pancho horrillo 01d1bf6038 doc/readme.rst: fix docker image build instructions 2019-07-01 15:42:16 +02:00
pancho horrillo 9d1937ebbf poc/examples/nmap/Dockerfile: make use of published docker image @ hub.docker.com 2019-07-01 15:37:47 +02:00
pancho horrillo 6af8fe7256 Merge branch 'develop' 2019-06-28 10:33:29 +02:00
pancho horrillo b058136eb2 poc/examples/pdfeditor/pdfeditor.pow: remove trailing whitespace 2019-06-27 10:12:08 +02:00
pancho horrillo 9b474d0d23 poc: add script for generating the docker image 2019-06-20 10:04:51 +02:00
pancho horrillo 4244ceba24 poc/examples/nmap/Dockerfile: revert version bump in base image 2019-06-19 11:48:57 +02:00
pancho horrillo 04715abbe1 poc/examples/nmap/Dockerfile: tidy it a little bit 2019-06-18 15:50:24 +02:00
pancho horrillo 1c7b2c5e96 poc/Dockerfile: tidy it a little bit 2019-06-18 15:49:57 +02:00
pancho horrillo 16145da7a5 README.md: fix style for clarity 2019-06-18 15:29:01 +02:00
pancho horrilloandCésar Gallego Rodríguez b0e640716f README.md: style fix
Co-authored-by: César Gallego Rodríguez <cesar.gallego.next@bbva.com>
2019-06-18 11:08:37 +02:00