What this guide covers
How do I scan an AI-generated TypeScript application with DerScanner security and code quality, remediate with a second Cursor prompt, and compare the results?
AI-assisted delivery can produce a working TypeScript service and a dozen security findings in one upload. Running the same scan settings again after a focused remediation prompt shows which rule families actually moved.
DerScanner runs security (SAST) and Code Quality (CQ) in one scan when you pass both languages and cqLanguages. The web interface shows each slice separately; a combined before/after view is built outside DerScanner from the scan API fields.
Everything below uses the DerScanner REST API with a named token on a local installation. Cloud DerScanner works the same way — replace the hostname in every command.
Before you start
- A DerScanner installation you can reach over HTTP, and an administrator account that can create users if needed.
- A user account for this work that is not the administrator account. The screenshots were taken under a dedicated account named Cursor.
- curl, or any HTTP client that can send multipart form data.
- Cursor or another AI coding tool for the generation and remediation prompts.
Environment
- DerScanner deployment
- Self-hosted installation on a single host at http://localhost/. Replace the host in every command with your own. Cloud DerScanner uses the same API paths under your tenant URL.
- Scan target
- Synthetic DeskQueue Express + TypeScript + SQLite service, about 520 lines in the baseline archive, generated from one prompt with no hand-edits before the first scan.
- Account used for screenshots
- Dedicated non-administrator account with scan quotas raised for the evaluation period.
- Baseline scan UUID
- 6ba0bae0-0555-4820-b117-fee5449c2af0 — 19 security findings (7 critical, 12 medium), score 25; CQ score 30 with 114 critical CQ findings across 436 LOC.
- After-remediation scan UUID
- bc7853a7-3c14-44a5-ad61-67bc91c3d742 — 13 security findings (5 critical, 8 medium), score 39; CQ score 63 with 41 critical CQ findings. Command injection, eval, and MD5 rule hits cleared.
The walkthrough
Step 1
Generate the application from one prompt
Start from code that was not reviewed line by line before the scan, the way AI-assisted delivery often works.
This guide uses a synthetic DeskQueue internal IT support service written for the walkthrough only. It is not a real product and was never deployed. The entire application under src/ was produced from one prompt in Cursor; nothing was edited by hand before the baseline scan.
The prompt asked for a small desk queue — staff login, searchable ticket lists, CSV reports that can be zipped, attachment upload, saved view presets from a desktop export, and admin endpoints for asset sync and server stats. It deliberately did not ask for security hardening, tests, or Docker.
Save the prompt text alongside the archive you upload so later readers can see what the model was asked to produce.
We need a small internal desk queue for IT support so people stop pinging us on
Slack for every laptop request. Build it with Express and TypeScript, SQLite is
fine.
What it has to do:
- staff log in with username and password
- list tickets with search (filter by whichever column the user picks) and sort
- create and update tickets, assign to a technician
- export a CSV report for a date range, optionally zip it for email
- upload and download attachments (screenshots, receipts)
- import a saved view preset from our desktop tool (it exports JSON we can load)
- admin endpoints: sync asset inventory script and show server stats
Keep it in a handful of files under src/, no ORM, plain SQL is fine. Skip tests
and Docker for now. We're behind schedule, just make it work.Step 2
Issue an API token
Drive both scans from a shell without installing anything into the IDE.
Request a token with the account credentials and a name you will recognise later. Send the access token as a bearer credential on every subsequent request.
If token creation returns SESSION_LIMIT_REACHED, revoke unused tokens or clear active JWT sessions on the installation before retrying.
curl -s -X POST "https://derscanner.example.com/app/api/v1/auth/jwt" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "username=$DERSCANNER_USER" \
--data-urlencode "password=$DERSCANNER_PASSWORD" \
--data-urlencode "token_name=deskqueue-api"
# {"accessToken":"eyJhbGciOiJIUzUxMiJ9..."}Step 3
Create a project and upload the archive
Keep baseline and rescan results under one project for comparison.
Create a SAST project for the DeskQueue sample, then reuse the same project UUID for the rescan after remediation.
Package the source as a zip archive. The scan uploads that archive directly; nothing needs to be checked into a repository the scanner can reach.
TOKEN="$DERSCANNER_TOKEN"
curl -s -X POST "https://derscanner.example.com/app/api/v1/projects" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "name=DeskQueue TypeScript sample"
# {"uuid":"f5ff71ef-4462-49dd-8907-fa21e963d47d", ...}Step 4
Run the baseline scan with SAST and Code Quality
Capture the first security and quality snapshot before any remediation.
Start the scan with languages=TYPESCRIPT and cqLanguages=TYPESCRIPT so DerScanner analyses security rules and code-quality rules in the same pass.
Keep AI triage flags off for every severity. The scan analyses the code and leaves every finding unverified until you choose otherwise.
The response returns the scan UUID to poll. On the baseline capture, DerScanner reported 19 security findings — seven critical and twelve medium — with a security score of 25 across 624 lines. Code Quality on the same scan reported a CQ score of 30 with 114 critical CQ findings across 436 analyzed lines.
TOKEN="$DERSCANNER_TOKEN"
PROJECT="f5ff71ef-4462-49dd-8907-fa21e963d47d"
curl -s -X POST "https://derscanner.example.com/app/api/v1/scan/start" \
-H "Authorization: Bearer $TOKEN" \
-F "file=@deskqueue-typescript.zip" \
-F "uuid=$PROJECT" \
-F "languages=TYPESCRIPT" \
-F "cqLanguages=TYPESCRIPT" \
-F "aiTriageCritical=false" \
-F "aiTriageMedium=false" \
-F "aiTriageLow=false" \
-F "aiTriageInfo=false" \
-F "applyTriage=false"
# {"projUuid":"f5ff71ef-...","scanUuid":"6ba0bae0-..."}Step 5
Read the baseline metrics
Record the numbers you will compare after remediation.
Poll the project scan list until status is COMPLETE. Each scan DTO includes security counts (critical, medium, low, info, score, loc) and quality counts (criticalCq, mediumCq, scoreCq, locCq).
The baseline scan surfaced command injection on shell-backed export and admin routes, eval on preset import, SQL injection on login and ticket search, weak MD5 password hashing, CSRF advisories, and a large CQ footprint — var usage, throw-literal throws, hardcoded paths, and camelCase violations.
DerScanner does not ship a single hybrid report that merges security and quality. Export the fields you need from the API or the statistics page, then assemble the combined view in Cursor Canvas or your own reporting tool.
TOKEN="$DERSCANNER_TOKEN"
PROJECT="f5ff71ef-4462-49dd-8907-fa21e963d47d"
BASELINE="6ba0bae0-0555-4820-b117-fee5449c2af0"
curl -s "https://derscanner.example.com/app/api/v1/projects/$PROJECT/scans?offset=0&limit=5" \
-H "Authorization: Bearer $TOKEN"
curl -s "https://derscanner.example.com/app/api/v1/scans/$BASELINE/issues?offset=0&limit=50" \
-H "Authorization: Bearer $TOKEN"Step 6
Review representative baseline findings
Connect rule IDs to concrete code patterns in the generated service.
Open the detailed results view for the baseline scan. The finding list groups issues by rule family — TS_INJECTION_COMMAND, TS_INJECTION_CODE, TS_INJECTION_SQL, TS_CRYPTO_BAD_HASH, TS_CSRF, and others.
Command injection findings point at execSync calls that interpolate user input into a shell command for zip export and asset sync.
Code injection comes from eval on preset import. SQL injection comes from string concatenation in login and ticket filter queries.
Step 7
Remediate with a second Cursor prompt
Fix vulnerabilities and hygiene issues without rewriting the feature set.
Send a second prompt that references the DerScanner results and asks for specific fixes — parameterized SQL, no eval, no shell execution for exports, bcrypt instead of MD5, environment-backed secrets, httpOnly cookies, and safe path handling for attachments.
The remediation prompt is saved as PROMPT-REMEDIATION.txt in the sample archive so the before/after provenance is clear.
Re-zip the project after Cursor applies the edits. Do not hand-tune findings to satisfy individual rules; the goal is the kind of fix batch a team would accept from an AI assistant after a scan.
The DeskQueue TypeScript service was scanned with DerScanner (SAST + Code Quality).
Fix every reported security issue and improve code quality without changing the
feature set.
- Replace string-concatenated SQL with parameterized queries everywhere.
- Remove eval and any dynamic code execution; parse JSON safely.
- Do not pass user input to shell commands; build zip archives in-process.
- Use bcrypt for password hashing instead of MD5.
- Read SESSION_SECRET and ADMIN_TOKEN from environment variables.
- Set session cookies httpOnly and sameSite=lax.
- Validate attachment download paths (basename only, no traversal).Step 8
Rescan with the same settings
Measure what changed under identical analysis configuration.
Upload the remediated archive to the same project with the same languages, cqLanguages, and triage flags as the baseline scan.
Poll until the second scan completes. Compare rule families, not only the aggregate score — LOC increased after adding bcrypt and archiver, which can move the headline score even when exploitable sinks are removed.
On this capture, command injection, code injection, and weak-crypto rule hits dropped to zero — ten SAST rule hits removed in total. Total security findings went from nineteen to thirteen. CQ score rose from 30 to 63 and critical CQ findings dropped from 114 to 41. CSRF advisories remain on some state-changing routes where static analysis does not recognize the custom CSRF middleware.
TOKEN="$DERSCANNER_TOKEN"
PROJECT="f5ff71ef-4462-49dd-8907-fa21e963d47d"
curl -s -X POST "https://derscanner.example.com/app/api/v1/scan/start" \
-H "Authorization: Bearer $TOKEN" \
-F "file=@deskqueue-typescript.zip" \
-F "uuid=$PROJECT" \
-F "languages=TYPESCRIPT" \
-F "cqLanguages=TYPESCRIPT" \
-F "aiTriageCritical=false" \
-F "aiTriageMedium=false" \
-F "aiTriageLow=false" \
-F "aiTriageInfo=false" \
-F "applyTriage=false"
# {"scanUuid":"bc7853a7-..."}Step 9
Confirm which rule families cleared
Show the delta a developer can act on.
Open the detailed results for the rescan. TS_INJECTION_COMMAND, TS_INJECTION_CODE, and TS_CRYPTO_BAD_HASH no longer appear.
Remaining findings on this capture are CSRF advisories, SQL and path rules on defensive code paths, and a reflected XSS rule on CSV export — useful input for a third remediation pass if you extend the guide.
Use the issues endpoint or the interface to export UUIDs if you later run selective DerTriage on individual rows.
Step 10
Build the baseline hybrid Canvas
Merge SAST metrics and hygiene context in one view DerScanner does not ship natively.
DerScanner exposes security and quality metrics separately in the scan DTO and Overview page. Pull critical, medium, score, loc, criticalCq, mediumCq, scoreCq, and locCq from the REST API, group findings by ruleId, and lay them out in a Cursor Canvas beside a hygiene checklist for the generated code.
The baseline hybrid report for this capture shows security score 25 with seven critical and twelve medium findings, plus CQ score 30 with 114 critical CQ findings — var usage, throw-literal, eval, and MD5 patterns dominate both slices.
Step 11
Build the after-remediation hybrid Canvas
Show which rule families cleared and which hygiene fixes landed.
Reuse the same Canvas layout with the rescan UUID. Swap the rule bar chart for the after capture and replace the hygiene checklist with the remediation changes Cursor applied — parameterized SQL, bcrypt, archiver-based zip export, environment-backed secrets, and httpOnly cookies.
Command injection, code injection, and weak-crypto rule hits drop to zero on this rescan. CQ score rises to 63 and critical CQ findings fall to 41 after removing var, eval, MD5, and throw-literal patterns.
Step 12
Compare rule families in one Canvas
Give stakeholders a delta view the native UI does not merge into a single panel.
Add a third Canvas that plots baseline and after counts side by side by rule family — command injection, eval, weak crypto, SQL rules, and CSRF advisories.
Include a short score context note. Aggregate security score moved from 25 to 39 because LOC grew after adding bcrypt, archiver, and CSRF middleware; CQ score moved from 30 to 63 as hygiene patterns were removed.
Step 13
Cross-check in DerScanner Scans Comparison
Pair the Canvas narrative with the native product view readers can open themselves.
Open Scans Comparison in DerScanner and select the baseline and after scans. The native chart shows remaining, fixed, and new findings by severity.
Use this view alongside the Canvas panels — product UI for drill-down, Canvas for the combined security-and-hygiene story you export to stakeholders.
Checking your result
Did command injection, eval, and weak-crypto findings clear after remediation?
Yes. Ten SAST rule hits across command injection, code injection, and weak-crypto families went to zero. Total security findings dropped from 19 to 13.
Did Code Quality improve on the rescan?
Yes. CQ score rose from 30 to 63 and critical CQ findings dropped from 114 to 41 on the captured local installation.
Can I run this workflow on cloud DerScanner?
Yes. Replace the hostname with your tenant URL. Project creation, scan upload, and polling use the same REST paths.
Does DerScanner include a built-in hybrid security and quality PDF?
No. Security and quality are separate slices in the product. Combine them in Cursor Canvas or your own reporting from the scan API fields.
Limits of this procedure
- This walkthrough uses a synthetic application with deliberate defects. Metrics describe that sample only.
- CSRF advisories remain after the captured remediation because the service does not implement CSRF tokens. Addressing them requires design changes beyond the second prompt.
- Aggregate security score can move independently of exploitability when LOC grows after remediation libraries are added. Compare rule families and CQ counts, not the headline security score alone.
- On the local mac-stack thin SAST image, TypeScript CQ requires the matcher CQ pass merged into the experimental sastx wrapper — without it, locCq stays zero even when cqLanguages is set.
Related knowledge
Canonical terms used: DerScanner; TypeScript; SAST; Code Quality; rescan; AI-generated code.
DerScanner