Skip to content

Commit

Permalink
Add README for running TensorFlow serving and testing the model
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Nov 23, 2023
1 parent 878af0c commit 53c05bf
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# DeepSQLi
Deep learning model, dataset, trained model and related code

Deep learning model, dataset, trained model and related code for SQL injection detection.

## TensorFlow Serving

### Install TensorFlow Serving

```bash
pip install tensorflow-serving-api
```

### Start TensorFlow Serving

```bash
docker run -t --rm --name serving -p 8500-8501:8500-8501 -v /home/mostafa/gatewayd/DeepSQLi/sqli_model:/models/sqli_model -e MODEL_NAME=sqli_model tensorflow/serving
```

These logs should appear:

```bash
...
2023-11-23 23:04:43.350127: I tensorflow_serving/model_servers/server.cc:409] Running gRPC ModelServer at 0.0.0.0:8500 ...
...
2023-11-23 23:04:43.351796: I tensorflow_serving/model_servers/server.cc:430] Exporting HTTP/REST API at:localhost:8501 ...
```

### Start Tokenizer API

```bash
cd api
./run.sh
```

### Test

```bash
# Tokenize and sequence the query
curl 'http://localhost:5000/tokenize_and_sequence' -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw '{"query":"select * from users where id = 1 or 1=1"}'
# Predict whether the query is SQLi or not
curl 'http://localhost:8501/v1/models/sqli_model:predict' -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw '{"inputs":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,21,4,32,3,10,3,3]]}'
```

0 comments on commit 53c05bf

Please sign in to comment.