Lint rule · ADN0505

adorn/no-sensitive-to-adorn-sink

Report where a @Sensitive value reaches one of adorn's own emitters (@Log, a violation-message parameter). Report-only: adorn secures its own emissions, not a raw console.log.

IdADN0505, the prefix of every message
recommendederror
stricterror
Fixableno
Needs type informationyes: a typed config (parserOptions.projectService)

What it reports

A value marked @Sensitive (a field, any field of a @Sensitive class, or a parameter) that reaches one of adorn's own emitters: a @Log method's parameter, or a violation-message parameter. The analysis follows the value through aliases, template interpolation and destructuring. It is the same analysis adorn check runs from the CLI.

Why

adorn redacts by default, and a @Sensitive marking vetoes disclosure even when it is turned on. But JavaScript passes a primitive by value, so once customer.ssn is handed to a parameter, the link back to the @Sensitive field is gone, and the receiving parameter has to be marked too.

Examples

Reported

reported by adorn/no-sensitive-to-adorn-sink
import { Log, Sensitive } from 'adorn';

class Customer { @Sensitive() ssn = ''; name = ''; }
class Audit { @Log() write(entry: string) { /* … */ } }

function record(c: Customer, audit: Audit) {
    audit.write(c.ssn);                    // Customer.ssn reaches @Log
}

Accepted

accepted
import { Log, Sensitive } from 'adorn';

class Customer { @Sensitive() ssn = ''; name = ''; }
class Audit { @Log() write(@Sensitive() entry: string) { /* … */ } }

function record(c: Customer, audit: Audit) {
    audit.write(c.ssn);
}

Details

Report-only, permanently: there is no fix, because the right fix (mark the receiver, or don't pass the value) is a judgement. adorn secures its own emitters, not a raw console.log, so that flow is out of scope, as is a derived value such as c.ssn.slice(-4).

To keep a finding on purpose, disable it with a reason, which justify-opt-out checks: // eslint-disable-next-line adorn/no-sensitive-to-adorn-sink -- <why>.

Messages

The text ESLint prints, read from the rule itself. {{…}} is filled in for each finding.

Message idText
sensitiveReachesEmitter[ADN0505] {{source}} ({{kind}}) reaches adorn emitter {{sink}} {{via}}. adorn will render this value; mark the receiving parameter @Sensitive, or do not pass it here.

All rules · the adorn/eslint guide