Skip to content

Commit

Permalink
Fix paths in message signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Giachetta committed Apr 24, 2019
1 parent e319323 commit 37b34d2
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions c-sharp/detectify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Detectify
/// <summary>
/// Detectify API endpoint, without a trailing slash.
/// </summary>
private const string Endpoint = "https://api.detectify.com/rest/v2";
private const string Endpoint = "https://api.detectify.com/rest";

private string ApiKey { get; }
private string SecretKey { get; }
Expand Down Expand Up @@ -84,7 +84,7 @@ private Dictionary<string, string> MakeHeaders(string method, string path,
/// <returns>Returns true if a scan was started, false if not.</returns>
public async Task<bool> StartScanAsync(string scanProfile)
{
var path = $"/scans/{scanProfile}/";
var path = $"/v2/scans/{scanProfile}/";
var url = $"{Endpoint}{path}";
var timestamp = DateTime.UtcNow;

Expand Down Expand Up @@ -139,7 +139,7 @@ public async Task<bool> StartScanAsync(string scanProfile)
/// <param name="scanProfile">The scan profile token to check scan status for.</param>
public async Task ScanStatusAsync(string scanProfile)
{
var path = $"/scans/{scanProfile}/";
var path = $"/v2/scans/{scanProfile}/";
var url = $"{Endpoint}{path}";
var timestamp = DateTime.UtcNow;

Expand Down
6 changes: 3 additions & 3 deletions java/Detectify.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Detectify {
/**
* Detectify API endpoint, no trailing slash
*/
private static final String Endpoint = "https://api.detectify.com/rest/v2";
private static final String Endpoint = "https://api.detectify.com/rest";

private String apiKey;
private String secretKey;
Expand Down Expand Up @@ -72,7 +72,7 @@ public boolean StartScan(String scanProfile) {
Date timestamp = new Date();

// Format API request URL
String path = String.format("/scans/%s/", scanProfile);
String path = String.format("/v2/scans/%s/", scanProfile);
String method = "POST";

URL url;
Expand Down Expand Up @@ -137,7 +137,7 @@ public void ScanStatus(String scanProfile) {
Date timestamp = new Date();

// Format API request URL
String path = String.format("/scans/%s/", scanProfile);
String path = String.format("/v2/scans/%s/", scanProfile);
String method = "GET";

URL url;
Expand Down
6 changes: 3 additions & 3 deletions node/detectify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const crypto = require('crypto')
const fetch = require('node-fetch')

// The endpoint to Detectify's API, no trailing slash
const DetectifyEndpoint = 'https://api.detectify.com/rest/v2'
const DetectifyEndpoint = 'https://api.detectify.com/rest'

// Generate the headers to use for API calls. If `secretKey` is not null, its value will be used to create
// the signature headers. `body` should be omitted unless the call requires a JSON payload.
Expand Down Expand Up @@ -43,7 +43,7 @@ function signatureHeaders(apiKey, secretKey, method, path, timestamp, body) {

// Starts a scan for the provided scan profile. Returns true if the scan was started, false if not.
function startScan(scanProfile, apiKey, secretKey) {
const path = `/scans/${scanProfile}/`
const path = `/v2/scans/${scanProfile}/`
const url = `${DetectifyEndpoint}${path}`
const timestamp = Math.floor(new Date() / 1000)

Expand Down Expand Up @@ -90,7 +90,7 @@ function startScan(scanProfile, apiKey, secretKey) {

// Returns the scan status as JSON if the scan is running.
function scanStatus(scanProfile, apiKey, secretKey) {
const path = `/scans/${scanProfile}/`
const path = `/v2/scans/${scanProfile}/`
const url = `${DetectifyEndpoint}${path}`
const timestamp = Math.floor(new Date() / 1000)

Expand Down
6 changes: 3 additions & 3 deletions php/detectify.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Detectify
{
// Detectify API endpoint, no trailing slash
private const ENDPOINT = "https://api.detectify.com/rest/v2";
private const ENDPOINT = "https://api.detectify.com/rest";

private $api_key;
private $secret_key;
Expand Down Expand Up @@ -48,7 +48,7 @@ function makeHeaders($method, $path, $timestamp, $body = null)
*/
function startScan($scan_profile)
{
$path = "/scans/$scan_profile/";
$path = "/v2/scans/$scan_profile/";
$url = self::ENDPOINT . $path;
$timestamp = time();

Expand Down Expand Up @@ -94,7 +94,7 @@ function startScan($scan_profile)
*/
function scanStatus($scan_profile)
{
$path = "/scans/$scan_profile/";
$path = "/v2/scans/$scan_profile/";
$url = self::ENDPOINT . $path;
$timestamp = time();

Expand Down
14 changes: 7 additions & 7 deletions python/detectify-2.7.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Detectify public API endpoint, no trailing slash
# Python 2.7
ENDPOINT = 'https://api.detectify.com/rest/v2'
ENDPOINT = 'https://api.detectify.com/rest'

# API response codes
response_codes = {
Expand Down Expand Up @@ -72,37 +72,37 @@ def request(api_key, secret_key, path, method):
return

def start_scan(scan_profile, api_key, secret_key):
path = "/scans/"+scan_profile+"/"
path = "/v2/scans/"+scan_profile+"/"
req = request(api_key, secret_key, path, 'POST')
if req != None:
print req.text

def stop_scan(scan_profile, api_key, secret_key):
path = "/scans/"+scan_profile+"/"
path = "/v2/scans/"+scan_profile+"/"
req = request(api_key, secret_key, path, 'DELETE')
if req != None:
print req.text

def scan_status(scan_profile, api_key, secret_key):
path = "/scans/"+scan_profile+"/"
path = "/v2/scans/"+scan_profile+"/"
req = request(api_key, secret_key, path, 'GET')
if req != None:
print req.text

def get_domains(api_key, secret_key):
path = "/domains/"
path = "/v2/domains/"
req = request(api_key, secret_key, path, 'GET')
if req != None:
print eval(req.text)

def get_domain_profiles(api_key, secret_key, domain_token):
path = "/profiles/"+domain_token+"/"
path = "/v2/profiles/"+domain_token+"/"
req = request(api_key, secret_key, path, 'GET')
if req != None:
print eval(req.text)

def get_all_profiles(api_key, secret_key):
path = "/profiles/"
path = "/v2/profiles/"
req = request(api_key, secret_key, path, 'GET')
if req != None:
return eval(req.text)
Expand Down
6 changes: 3 additions & 3 deletions python/detectify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time

# Detectify public API endpoint, no trailing slash
ENDPOINT = 'https://api.detectify.com/rest/v2'
ENDPOINT = 'https://api.detectify.com/rest'


def make_headers(api_key, secret_key, method, path, timestamp, body=None):
Expand Down Expand Up @@ -35,7 +35,7 @@ def make_signature(api_key, secret_key, method, path, timestamp, body=None):


def start_scan(scan_profile, api_key, secret_key):
path = f"/scans/{scan_profile}/"
path = f"/v2/scans/{scan_profile}/"
url = f"{ENDPOINT}{path}"
timestamp = int(time.time())
headers = make_headers(api_key, secret_key, 'POST', path, timestamp)
Expand Down Expand Up @@ -64,7 +64,7 @@ def start_scan(scan_profile, api_key, secret_key):


def scan_status(scan_profile, api_key, secret_key):
path = f"/scans/{scan_profile}/"
path = f"/v2/scans/{scan_profile}/"
url = f"{ENDPOINT}{path}"
timestamp = int(time.time())
headers = make_headers(api_key, secret_key, 'GET', path, timestamp)
Expand Down
6 changes: 3 additions & 3 deletions ruby/detectify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

module Detectify
# Base endpoint to the Detectify API, no trailing slash
ENDPOINT = 'https://api.detectify.com/rest/v2'.freeze
ENDPOINT = 'https://api.detectify.com/rest'.freeze

# Generates signature headers. Returns a map of headers to pass along with the call.
def self.signature(api_key, secret_key, method, url, timestamp, body='')
Expand Down Expand Up @@ -40,7 +40,7 @@ def self.create_headers(method, path, api_key, secret_key = nil)
# Starts a new scan on the provided scan profile. Returns true if the scan was started,
# false if it was not started.
def self.start_scan(scan_profile, api_key, secret_key=nil)
path = "/scans/#{scan_profile}/"
path = "/v2/scans/#{scan_profile}/"
url = "#{ENDPOINT}#{path}"

# Create headers for the call
Expand Down Expand Up @@ -83,7 +83,7 @@ def self.start_scan(scan_profile, api_key, secret_key=nil)

# Prints the status of a currently running scan.
def self.scan_status(scan_profile, api_key, secret_key = nil)
path = "/scans/#{scan_profile}/"
path = "/v2/scans/#{scan_profile}/"
url = "#{ENDPOINT}#{path}"

# Create headers for the call
Expand Down

0 comments on commit 37b34d2

Please sign in to comment.