// npm package
@antv/narrative-text-schema
Json schema of narrative text visualization
versions
14
maintainers
51
license
MIT
first publish
2022-02-15
publisher
bbsqq
tarball
691,256 B
AUTO-PUBLISHED·1 version indexed·latest published 2022-10-26
// publisher campaignby bbsqq
5 caught packages from this accountThis is not an isolated catch. The same publisher has shipped 4 other packages that our pipeline flagged — the shape of a coordinated campaign, not a one-off. Each link below opens that sibling's analysis.
// offending code· @0.3.7· 3 files flagged
llm: benign · 0.85→ No suspicious destination, no remote-exec shape — 1 known-vendor host(s).
- @0.3.7··AUTO-PUBLISHED·publisher: bbsqqheuristic 75/100static flags 1llm benign (0.85) via ollamamature-packageosv-flagged:MAL-2026-4073child-process-spawn
→ No suspicious destination, no remote-exec shape — 1 known-vendor host(s).
// offending code· 3 files flaggedpatterns: 1
--- package/src/tools/template.ts (excerpt) --- import { PhraseSpec, EntityType } from '../schema'; /** * parse string template to phrases * @example * str = `<%= time %>, <%= columnAlias$$metric_name$$ %> is <%= price$$metric_value$$ %>` * data = { time: "2020", columnAlias: "price total", price: "123" } * => * [ * { type: "text", value: "2020" }, * { type: "text", value: ", " }, * { type: "entity", value: "price total", metadata: { entityType: metric_name } }, * { type: "text", value: " is " }, * { type: "entity", value: "123", metadata: { entityType: metric_value } }, * ] */ export function generateSentence( template: string, formattedData?: Record<string, string>, originalData?: Record<string, unknown>, ): PhraseSpec[] { const splitReg = /(<%= [\s\S]*?(::\w*?)? %>)/; const variableReg = /<%= ([\s\S]*?)(\$\$(\w*)\$\$)? %>/; return template.split(splitReg).reduce<PhraseSpec[]>((prev, curr) => { if (curr) { const variable = variableReg.exec(curr); if (variable && variable[1] && formattedData && typeof formattedData[variable[1]] === 'string') { const formattedVal = formattedData[variable[1]]; if (variable[3]) { const eType = variable[3] as EntityType; const result: PhraseSpec = { type: 'entity', value: formattedVal, metadata: { entityType: eType, }, }; const origin = originalData ? originalData[variable[1]] : undefined; if ( --- package/src/generate/generateTextSpec.ts (excerpt) --- import { isUndefined, arr2map } from '../utils'; import type { NarrativeTextSpec, ParagraphSpec, PhraseSpec, TextParagraphSpec, TextPhraseSpec } from '../schema'; import type { Structure, Variable, StructureTemp } from './types'; /** * use structure and variables to generate narrative text spec */ function generateTextSpec({ structures, structureTemps = [], variables = [], }: { structures: Structure[]; structureTemps?: StructureTemp[]; variables?: Variable[]; }): NarrativeTextSpec { const variableMap = arr2map<Variable>(variables, 'variableId'); const structureTempMap = arr2map<StructureTemp>(structureTemps, 'templateId'); const splitReg = /(&{.*?})/; const varReg = /&{(.*?)}/; // generate paragraphs by structure let paragraphs: ParagraphSpec[] = []; structures.forEach((structure, structureIdx) => { const { template } = structure; let { displayType = structureIdx === 0 ? 'paragraph' : 'phrase' } = structure; // "System &{s1}, includes &{s2}." => ["System ", "&{s1}", ", includes ", "&{s2}", "."] const templateStrArr = template.split(splitReg).filter((str) => str); templateStrArr.forEach((templateStr, structureTempIdx) => { const templateId: string | undefined = varReg.exec(templateStr)?.[1]; if (structureTempIdx > 0) displayType = 'phrase'; if (templateId && structureTempMap[templateId]) { const structureTemp = structureTempMap[templateId]; const { template: subTemplate, variableId, separator --- package/lib/tools/template.js (excerpt) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateSentence = void 0; /** * parse string template to phrases * @example * str = `<%= time %>, <%= columnAlias$$metric_name$$ %> is <%= price$$metric_value$$ %>` * data = { time: "2020", columnAlias: "price total", price: "123" } * => * [ * { type: "text", value: "2020" }, * { type: "text", value: ", " }, * { type: "entity", value: "price total", metadata: { entityType: metric_name } }, * { type: "text", value: " is " }, * { type: "entity", value: "123", metadata: { entityType: metric_value } }, * ] */ function generateSentence(template, formattedData, originalData) { var splitReg = /(<%= [\s\S]*?(::\w*?)? %>)/; var variableReg = /<%= ([\s\S]*?)(\$\$(\w*)\$\$)? %>/; return template.split(splitReg).reduce(function (prev, curr) { if (curr) { var variable = variableReg.exec(curr); if (variable && variable[1] && formattedData && typeof formattedData[variable[1]] === 'string') { var formattedVal = formattedData[variable[1]]; if (variable[3]) { var eType = variable[3]; var result = { type: 'entity', value: formattedVal, metadata: { entityType: eType, }, }; var origin_1 = originalData ? o
