Skip to content

feat: add NsesApi — REST CRUD endpoints for NSE script management #172

@t0kubetsu

Description

@t0kubetsu

Problem

NSE scripts can only be managed through the /nsesview HTML form interface. There are no REST API endpoints for NSE scripts, making programmatic management (upload, update, delete) impossible without scraping HTML and CSRF tokens.

Proposed solution

Add a new NsesApi(BaseApi) class at /api/v1/nses with full CRUD:

Method Path Action
GET /api/v1/nses/ list all NSE scripts ({id, name, hash})
POST /api/v1/nses/ upload a new .nse file (multipart filebody); upserts on name collision
GET /api/v1/nses/<pk> read a single script by ID
PUT /api/v1/nses/<pk> update file content and/or rename in-place
DELETE /api/v1/nses/<pk> delete by ID

All endpoints use @protect() (JWT or session auth) and @safe.

The PUT endpoint:

  • accepts an optional filebody multipart file and/or an optional name form field (at least one required)
  • validates the .nse extension on upload
  • rejects SHA-256 hash collisions with other records
  • uses FileManager to replace the file on disk atomically

Motivation

External automation clients need a stable REST interface to manage deployed NSE scripts without recycling IDs or scraping HTML forms. An in-place PUT avoids the race-condition window between delete and re-create.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions