← Attack Surface Lab

Code Patterns

Endpoints built through object-oriented classes, DOM APIs, and framework-specific AJAX patterns. These test whether the analyzer understands how real-world JavaScript constructs HTTP requests.

01

ES6 class resolves this.baseURL

A class sets this.baseURL in the constructor and concatenates it in a method. The analyzer must track this inside class methods.

Client-side JavaScript notificationService.js
class NotificationService {
  constructor() {
    this.baseURL = "/api/notifications";
  }

  getUnread() {
    return fetch(this.baseURL + "/unread");
  }
}
SolidPoint discovered
SolidPoint UI showing discovered GET /api/notifications/unread endpoint
02

Global variable with jQuery $.ajax()

A global variable holds the API prefix. jQuery's $.ajax() builds the request. Two functions, two endpoints.

Client-side JavaScript bookmarkManager.js
var bookmarkApi = "/api/bookmarks";

function saveBookmark(data) {
  $.ajax({
    url: bookmarkApi + "/save",
    method: "POST",
    data: data
  });
}

function removeBookmark(id) {
  $.ajax({
    url: bookmarkApi + "/remove",
    method: "DELETE",
    data: { id: id }
  });
}
SolidPoint discovered
SolidPoint UI showing discovered POST /api/bookmarks/save endpoint SolidPoint UI showing discovered DELETE /api/bookmarks/remove endpoint
03

Prototype class, never instantiated

Old-style constructor function with prototype methods. this.baseURL is set in init(), used in track(). The class is never instantiated with new.

Client-side JavaScript analyticsClient.js
function AnalyticsClient() {}

AnalyticsClient.prototype.init = function () {
  this.baseURL = '/api/analytics/';
};

AnalyticsClient.prototype.track = function (event, data) {
  fetch(this.baseURL + 'track', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ event: event, data: data })
  });
};

// Class defined but NEVER instantiated.
// No `new AnalyticsClient()` anywhere on the page.
SolidPoint discovered
SolidPoint UI showing discovered POST /api/analytics/track endpoint
04

XMLHttpRequest raw sink

xhr.open('POST', url) followed by xhr.send(data). The legacy browser API β€” no library, no wrapper. The analyzer must recognize XMLHttpRequest as an HTTP sink.

Client-side JavaScript telemetryBeacon.js
function sendBeacon(payload) {
  var xhr = new XMLHttpRequest();
  xhr.open("POST", "/api/telemetry/beacon");
  xhr.setRequestHeader("Content-Type", "application/json");
  xhr.send(JSON.stringify(payload));
}
SolidPoint discovered
SolidPoint UI showing discovered POST /api/telemetry/beacon endpoint
05

axios library sink

axios.get() with a global variable prefix. The analyzer must recognize the axios library as an HTTP sink alongside native fetch() and XMLHttpRequest.

Client-side JavaScript feedClient.js
const feedApi = "/api/feed";

const loadLatestFeed = async () => {
  const res = await axios.get(feedApi + "/latest");
  console.log(res.data);
};
SolidPoint discovered
SolidPoint UI showing discovered GET /api/feed/latest endpoint
06

window.location assignment

window.location = url β€” not a traditional AJAX call, but triggers a server request.

Client-side JavaScript exportRedirect.js
const downloadExport = (format) => {
  const url = "/api/export/download";
  window.location = url;
};
SolidPoint discovered
SolidPoint UI showing discovered GET /api/export/download endpoint
07

fetch() with encodeURIComponent()

A built-in browser function wraps a parameter inside the URL expression. The analyzer must evaluate through it.

Client-side JavaScript searchBar.js
const executeSearch = (query) => {
  const url = "/api/search/query?q=" +
    encodeURIComponent(query);
  fetch(url);
};
SolidPoint discovered
SolidPoint UI showing discovered GET /api/search/query endpoint
08

Angular $http.post() sink

AngularJS $http service β€” a framework-specific HTTP client. The analyzer must recognize framework APIs as sinks, not just native browser functions.

Client-side JavaScript angularHttpClient.js
var settingsApi = "/api/user/settings";

function saveUserSettings(prefs) {
  $http.post(settingsApi + "/save", prefs);
}
SolidPoint discovered
SolidPoint UI showing discovered POST /api/user/settings/save endpoint

Start boosting your App Security testing today with us today

Try for free Get a demo