Commit Graph
100 Commits
Author SHA1 Message Date
pancho horrilloandRoberto Abdelkader Martínez Pérez 4d2f0af941 doc: markup curl as program role
See ¹.

¹: https://www.sphinx-doc.org/en/1.5/markup/inline.html#role-program

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-12-11 11:43:04 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 3bed9924d5 doc: make example script downloadable
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@bbva.com>
2019-12-11 10:45:48 +01:00
pancho horrillo 375cf7e912 doc: fix title 2019-12-11 03:37:19 +01:00
pancho horrillo ec4143393a doc: tweak code-block language to activate syntax highlighting 2019-12-11 03:35:12 +01:00
pancho horrillo b1d0e9c92f doc: use valid language in code-blocks
See ¹ for the valid values.

¹: https://www.sphinx-doc.org/en/1.5/markup/code.html#directive-code-block
2019-12-11 03:23:56 +01:00
pancho horrillo 9436548d7b doc: normalize code-block type 2019-12-11 03:13:28 +01:00
pancho horrillo c974e7787e doc: tweak code-block to fix render glitch at readthedocks.io 2019-12-11 03:10:55 +01:00
pancho horrillo deceadcc49 doc: misc fixes 2019-12-11 02:49:37 +01:00
pancho horrillo e6cb0f1fa6 doc: fix typo and rst style fixes
As per the official docs¹, we should use ``code`` instead of :samp:`code`,
since we are not enhancing variables inside.

:samp:
A piece of literal text, such as code. Within the contents, you can use curly
braces to indicate a “variable” part, as in file. For example, in :samp:`print
1+{variable}`, the part variable would be emphasized.

If you don’t need the “variable part” indication, use the standard ``code``
instead.

¹: https://www.sphinx-doc.org/en/1.5/markup/inline.html#role-samp
2019-12-11 02:37:56 +01:00
pancho horrillo 16639ba44b doc: style fixes 2019-12-11 02:32:52 +01:00
pancho horrillo 37025211b1 doc: style fixes 2019-12-11 02:06:31 +01:00
pancho horrillo 68efc98964 doc: consistent naming of pow files 2019-12-11 02:04:11 +01:00
pancho horrillo ef838c4a25 doc: style fix 2019-12-10 18:23:23 +01:00
pancho horrillo ba6006fdf5 doc: fix typo 2019-12-10 18:15:29 +01:00
pancho horrillo a9328fe706 doc: consistent naming of pow files 2019-12-10 18:10:31 +01:00
pancho horrillo ae68cf8fed doc: tutorial style fixes 2019-12-10 18:01:54 +01:00
pancho horrillo 99167e8627 doc: tutorial background story fixes 2019-12-10 16:19:06 +01:00
pancho horrillo cbacacf8e1 doc: tutorial background story fixes 2019-12-10 16:15:40 +01:00
pancho horrillo b4bc08f491 doc: typos and style fixes 2019-12-10 16:09:35 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez bb4aa1a00f doc: normalize style of Kapow!, to be shown italicized
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-12-10 10:34:39 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 166c767317 doc: add section on security and misc fixes
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-12-05 18:30:35 +01:00
pancho horrilloandLuis Saiz 8248627f04 doc: misc fixes
Co-authored-by: Luis Saiz <luis.saiz@bbva.com>
2019-11-29 12:57:45 +01:00
pancho horrillo 2e1455cb61 Revert "Update quickstart.rst"
This reverts commit 7fab8ae529.
2019-11-29 10:20:40 +01:00
pancho horrillo f1bdc99267 doc: drop dangling link 2019-11-28 10:44:53 +01:00
pancho horrillo 34a5960b3c doc: fix wording 2019-11-27 16:13:32 +01:00
pancho horrillo 53b326cb7b doc: style fixes, example code fixes and clarifications 2019-11-27 16:07:23 +01:00
pancho horrillo 530fad17c9 doc: fix typo 2019-11-27 07:53:56 +01:00
pancho horrilloandHector Hurtado d08c6c72e7 doc: more work on _brainstorming.rst
Co-authored-by: Hector Hurtado <hector.hurtado@bbva.com>
2019-11-25 18:05:50 +01:00
pancho horrillo 6b2e2dfb28 RELEASE-v0.3.0.md: fix title 2019-11-22 17:03:54 +01:00
pancho horrillo 235375c199 RELEASE-v0.3.0.md: fix title 2019-11-22 16:51:19 +01:00
pancho horrillo 2f70938dc4 RELEASE-v0.3.0.md: fix link format and main title 2019-11-22 15:42:56 +01:00
pancho horrillo 07c6c42b73 Add release notes for v0.3.0 2019-11-22 15:39:19 +01:00
pancho horrillo ce83cac13e README.md: minor style fixes 2019-11-22 14:20:10 +01:00
pancho horrillo 0b0defd132 README.md: misc style fixes 2019-11-22 14:15:24 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 26145cba79 doc: updates to route_matching section
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-22 12:13:25 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez f9867fb269 doc: add sections on theory/{routes,route_matching}
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-22 12:04:49 +01:00
pancho horrillo 8474f31747 doc: update request_life_cycle.rst 2019-11-22 09:20:29 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 24cc530a0e doc: add missing quotes in example
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-21 13:12:19 +01:00
pancho horrillo 8f876ba7db doc: fix a couple of typos and drop spurious whitespace 2019-11-21 10:36:46 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez ae0c8b58a1 Misc doc updates
Co-Authored-By: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-20 16:37:00 +01:00
pancho horrillo 25d9f1c1ef Delete placeholder 2019-11-20 16:16:32 +01:00
pancho horrillo e5e8da551e docs/philosophy.rst: style fixes 2019-11-20 14:30:28 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 5ee8353cba WIP on docs/theory
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-20 12:54:29 +01:00
pancho horrillo 206aac5747 Rename package srverrors to httperror
- Package names are preferred to be in singular form¹.
- Since errors are just for HTTP and not generic, I changed the base name to
'http'.
- I didn't name it simply 'error', because it would then conflict with the
- standard 'error' interface.

¹: https://rakyll.org/style-packages/
2019-11-20 07:54:45 +01:00
pancho horrillo 0d66fe9963 Rename WriteErrorResponse() to simply ErrorJSON() and reorder arguments
This way we better mimic net/http.Error()

https://pkg.go.dev/net/http?tab=doc#Error
2019-11-20 07:37:35 +01:00
pancho horrillo 7ea43048bc Add missing comments 2019-11-20 07:14:00 +01:00
pancho horrillo d81ef278da Update Makefile to make use of -trimpath build option
This option makes go build/install removes the absolute paths
within the produced executable, enabling more reproducible builds.

See ¹ for more details.

¹: https://golang.org/doc/go1.13?ref=hvper.com#go-command
2019-11-20 06:43:40 +01:00
pancho horrillo 75b0908b16 Rename GetReasonFromBody() to simply Reason()
See ¹ for the customary idiomatic way of naming getters in Go.

¹: https://golang.org/doc/effective_go.html#Getters
2019-11-20 05:04:10 +01:00
pancho horrillo 3a47b34bc1 Drop stale GetReason() and associated tests 2019-11-20 04:54:07 +01:00
pancho horrillo b40f73115f Add missing comment to GetReasonFromBody() 2019-11-20 04:51:29 +01:00
pancho horrillo b130cfdec7 Add some examples
Note that the example on redirecting a URL is BROKEN.  Possibly a bug in Kapow!
2019-11-19 21:52:10 +01:00
pancho horrillo 81c677c3be internal/http/request.go: replace GetReason() with GetReasonFromBody()
Update tests to inject the required JSON error body with reason.
2019-11-19 21:17:49 +01:00
pancho horrillo e7619238ae Add GetReasonFromBody() that extracts reason from JSON 2019-11-19 21:17:34 +01:00
pancho horrillo 28f4b969f9 Update go.{mod,sum} recreating them from scratch
$ rm go.{mod,sum}; go mod init github.com/BBVA/kapow
go: creating new go.mod: module github.com/BBVA/kapow
$ go mod tidy -v
go: finding github.com/google/shlex latest

With this, we've gotten rid an unneeded dep (github.com/spf13/pflag @ v1.0.5).
2019-11-19 17:50:16 +01:00
pancho horrillo 806905c49c Update go.{mod,sum}
Set base version to go 1.13

and run:

$ go mod tidy -v
unused github.com/gogo/protobuf
unused github.com/golangci/gocyclo
unused github.com/golangci/golangci-lint
unused github.com/golangci/revgrep
unused github.com/gostaticanalysis/analysisutil
unused github.com/konsorten/go-windows-terminal-sequences
unused github.com/magiconair/properties
unused github.com/mattn/go-isatty
unused github.com/pelletier/go-toml
unused github.com/securego/gosec
unused github.com/spf13/afero
unused github.com/spf13/jwalterweatherman
unused github.com/uudashr/gocognit
unused golang.org/x/sys
unused golang.org/x/tools
unused mvdan.cc/unparam
unused sourcegraph.com/sqs/pbtypes
2019-11-19 17:32:28 +01:00
pancho horrillo 83e4523dc7 Simplify files via gofmt -s (thanks, Go Report Card!) 2019-11-19 14:14:55 +01:00
pancho horrillo 92fbb72735 Fix typos catched via misspell (thanks Go Report Card!) 2019-11-19 14:07:58 +01:00
pancho horrillo 1249b23458 Fix case mismatch in error JSON (adding tag) 2019-11-18 17:44:39 +01:00
pancho horrillo 402bbf00d7 Fix style in comment 2019-11-15 21:00:21 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 3af5def406 poc: make error_body(reason) return a JSON with extraneous fields
We then ensure that the cucumber steps only test the
presence of the required fields, not just comparing it byte-wise.

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-14 17:40:47 +01:00
03de51e6ca Fix missing quotes in step
Co-authored-by: César Gallego Rodríguez <cesar.gallego.next@bbva.com>
Co-Authored-By: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-14 17:13:34 +01:00
pancho horrillo 9ebc989bc7 poc/Makefile: add 'fix' target (mirroring spec/Makefile) 2019-11-14 17:53:32 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 3e2bc44c0b spec/Makefile: on fix target, skip tagged scenarios and features
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-14 17:53:02 +01:00
pancho horrillo f43e47f4f1 Remove leftover script 2019-11-14 11:57:44 +01:00
pancho horrillo 2d5743af84 Add blank line between legal header and package declaration
Otherwise, the legal header is rendered as package documentation.
2019-11-13 18:18:44 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 822e4f85df spec: clarify the order of the execution of the tests
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-11 18:02:07 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 6194c6961a Tweak PoC to pass current test suite
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-11 17:47:28 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez e4606ab84a Drop compound error scenario
In order to allow different Kapow! implementations (Go, Python, ...)
compound errors will be left as implementation-dependent.
The spec will only test for simple error conditions.

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-11 17:47:28 +01:00
pancho horrilloandRoberto Abdelkader Martínez Pérez 9eb186bd0f Revert "Closes: #66"
This reverts commit c3be29255a.

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-11-11 17:47:20 +01:00
pancho horrillo fe303d4d02 README.rst: Fix heading 2019-11-03 23:39:21 +01:00
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