Skip to content

Okwori/polylith-example

Repository files navigation

Centripetal Network Assignment

Your objective is to build a simple JSON based REST Microservice. The service will provide search capabilities on an open source intelligence feed provided by AlienVault OTX. REST and microservices are fairly common, the goal here is to show how this might be done in a Clojure application using its functional capabilities.

Prerequisites

Tools

Helpful Libs

Running

Run Locally

# Run the application
make run
# Or build and run the JAR
make build
make run-jar

Via Docker

# Build and run
make docker-build
make docker-run

# Or stop the container
make docker-stop

Usage

API UI

http://localhost:8080/api-docs

Endpoints

  • GET /indicators/:id : Note: This currently uses document/id, which is the top-level string ID. Alternatively, indicator/id (a long value within the inner vector) could be what is expected?
# curl http://localhost:8080/indicators/5b433d8fe822e72e3c57d26c
make api-indicator ID=5b3cb789bd391e24a8b1dc53
  • GET /indicators :
# curl http://localhost:8080/indicators
make api-indicators
  • GET /indicators?type=IPv4 :
# curl "http://localhost:8080/indicators?type=IPv4"
make api-indicators-type TYPE=IPv4
  • POST /indicators/search :
# curl -X POST http://localhost:8080/indicators/search \
#  -H "Content-Type: application/json" \
#  -d '{"adversary": "Plead"}'
make api-search QUERY='{"adversary":"Plead"}'
# curl -X POST http://localhost:8080/indicators/search \
#  -H "Content-Type: application/json" \
#  -d '{"author_name": "AlienVault"}'
make api-search QUERY='{"author_name":"AlienVault"}'

Search Criteria Options

Field Type Example
adversary string {"adversary": "Plead"}
tlp string {"tlp": "white"}
author_name string {"author_name": "AlienVault"}
tags string or array {"tags": "china"} or {"tags": ["china", "apt"]}
industries string or array {"industries": "tech"}
targeted_countries string or array {"targeted_countries": "Kuwait"}
revision number {"revision": 1}
public number (0 or 1) {"public": 1}
  • Check Health
make api-health

Explore Project

make info

Check Code Formatting

make format-check

Available Commands

Command Description
make run Run application locally
make run-jar Build and run the JAR file
make build Build uberjar
make clean Clean build artifacts
make test Run unit tests
make format-check Check code formatting
make docker-build Build Docker image
make docker-run Run Docker container
make docker-stop Stop Docker container
make docker-clean Remove Docker image
make info Show project information

Testing

WIP on unit and integration testing with Speclj and Etaoin.

However, you can run the existing Clojure unit tests::

make test

Reference

Created by: Simon Okwori

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors