diff --git a/README.org b/README.org index 33c9ae1..721d4c4 100644 --- a/README.org +++ b/README.org @@ -1,29 +1,31 @@ * Introduction to hepc -- HTTP End Point for CodeQL ** Usage Sample #+BEGIN_SRC sh - # Collect DBs from filesystem - cd ~/work-gh/mrva/mrvahepc && rm -fR db-collection.tmp/ - ./bin/mc-hepc-init --db_collection_dir db-collection.tmp \ - --starting_path ~/work-gh/mrva/mrva-open-source-download \ - --max_dbs 17 + # Collect DBs from filesystem + cd ~/work-gh/mrva/mrvahepc && rm -fR db-collection.tmp/ + export MRVA_HEPC_ENDPOINT=http://hepc + ./bin/mc-hepc-init --db_collection_dir db-collection.tmp \ + --starting_path ~/work-gh/mrva/mrva-open-source-download \ + --max_dbs 17 - # Serve collected DBs plus metadata - cd ~/work-gh/mrva/mrvahepc - . venv/bin/activate - ./bin/mc-hepc-serve --codeql-db-dir db-collection.tmp + # Serve collected DBs plus metadata + cd ~/work-gh/mrva/mrvahepc + . venv/bin/activate - # Test server - curl 127.0.0.1:8070/index -o - 2>/dev/null | wc -l + ./bin/mc-hepc-serve --codeql-db-dir db-collection.tmp - curl 127.0.0.1:8070/api/v1/latest_results/codeql-all \ - -o - 2>/dev/null | wc -l + # Test server + curl 127.0.0.1:8070/index -o - 2>/dev/null | wc -l - url=$(curl 127.0.0.1:8070/api/v1/latest_results/codeql-all \ - -o - 2>/dev/null | head -1 | jq -r .result_url) - echo $url - # http://hepc/db/db-collection.tmp/aircrack-ng-aircrack-ng-ctsj-41ebbe.zip + curl 127.0.0.1:8070/api/v1/latest_results/codeql-all \ + -o - 2>/dev/null | wc -l - wget $(echo $url|sed 's|http://hepc|http://127.0.0.1:8070|g;') + url=$(curl 127.0.0.1:8070/api/v1/latest_results/codeql-all \ + -o - 2>/dev/null | head -1 | jq -r .result_url) + echo $url + # http://hepc/db/db-collection.tmp/aircrack-ng-aircrack-ng-ctsj-41ebbe.zip + + wget $(echo $url|sed 's|http://hepc|http://127.0.0.1:8070|g;') #+END_SRC diff --git a/bin/mc-hepc-init b/bin/mc-hepc-init index e34ee6c..28684bf 100755 --- a/bin/mc-hepc-init +++ b/bin/mc-hepc-init @@ -52,10 +52,15 @@ def process_db_file(zip_path, db_collection_dir): source_location_prefix = local.path(yaml_data["sourceLocationPrefix"]) repo = source_location_prefix.name owner = source_location_prefix.parent.name - cid = generate_cid(cli_version, creation_time, primary_language, sha) + cid = generate_cid(cli_version, creation_time, primary_language, sha) new_db_fname = f"{owner}-{repo}-ctsj-{cid}.zip" - result_url = f"http://hepc/db/{db_collection_dir}/{new_db_fname}" - + hepc_endpoint = os.getenv("MRVA_HEPC_ENDPOINT") + if hepc_endpoint is None: + log("WARN", "Environment variable 'MRVA_HEPC_ENDPOINT' is not set." + "Using default 'http://hepc'.") + hepc_endpoint = "http://hepc" + result_url = f"{hepc_endpoint}/db/{db_collection_dir}/{new_db_fname}" + metadata = { "git_branch" : "HEAD", "git_commit_id" : sha, diff --git a/mrvahepc.code-workspace b/mrvahepc.code-workspace new file mode 100644 index 0000000..517e0b2 --- /dev/null +++ b/mrvahepc.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file