
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
typeorm-stubs
Advanced tools
Stubs generator for
Typeormentities. It usestypeorm metadatato get the type of the column and generate a random value.
You may generate a single stub or an array of stubs from Typeorm entity like this:
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn('uuid')
public id: string;
@CreateDateColumn()
public createdAt: Date;
@Column({ type: 'varchar', nullable: false })
public name: string;
@Column({ type: 'integer', nullable: false })
public index: number;
@Column({ type: 'boolean', nullable: false })
public isMain: boolean;
}
This code generates a single stub:
const stub = new Stub().createOne(MyEntity);
It gives you an object like this:
const stub: MyEntity = {
id: '125a1c28-2938-4996-95f0-d768cbc3c15e',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
name: 'Proin interdum adipiscing vel tortor.',
index: 487,
isMain: true,
}
For an array of stubs use this code:
const stubs = new Stub().createMany(MyEntity, 5);
It gives you 5 stubs in array. Param count is optional and can be omitted, then random count of stubs will be generated.
You may create a stub from entity with relations, e.g.:
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn('uuid')
public id: string;
@CreateDateColumn()
public createdAt: Date;
@Column({ type: 'varchar', nullable: false })
public name: string;
@Column({ type: 'integer', nullable: false })
public index: number;
@Column({ type: 'boolean', nullable: false })
public isMain: boolean;
@Column({ type: 'uuid', nullable: true })
public relationId?: string;
@ManyToOne(() => RelationEntity)
@JoinColumn({ name: 'relationId' })
public relation?: RelationEntity;
}
@Entity()
export class RelationEntity {
@PrimaryGeneratedColumn('uuid')
public id: string;
@CreateDateColumn()
public createdAt: Date;
@Column({ type: 'varchar', nullable: false })
public description: string;
@OneToMany(() => DeepRelation)
public deepRelations: DeepRelation[];
}
@Entity()
export class DeepRelation {
@PrimaryGeneratedColumn('uuid')
public id: string;
@CreateDateColumn()
public createdAt: Date;
@Column({ type: 'integer', nullable: false })
public index: number;
@Column({ type: 'uuid', nullable: true })
public parentId?: string;
@ManyToOne(() => RelationEntity)
@JoinColumn({ name: 'relationId' })
public parent?: RelationEntity;
}
It gives:
const stub: MyEntity = {
id: '125a1c28-2938-4996-95f0-d768cbc3c15e',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
name: 'Proin interdum adipiscing vel tortor.',
index: 487,
isMain: true,
relationId: '3631150a-c6be-4fab-9896-182e67056efe',
relation: {
id: '3631150a-c6be-4fab-9896-182e67056efe',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
description: 'Sit ut, mattis cursus. porttitor feugiat sit malesuada vitae.',
deepRelations: [
{
id: '7d8b2f6b-bd52-424a-adcf-770a979690d1',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
index: 15,
parentId: '3631150a-c6be-4fab-9896-182e67056efe',
},
{
id: '02abe928-08e5-412a-957b-7a45382df9fc',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
index: 8,
parentId: '3631150a-c6be-4fab-9896-182e67056efe',
},
{
id: '74a1ded5-e9d9-4fd4-bb1e-161d4d0df412',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
index: 593,
parentId: '3631150a-c6be-4fab-9896-182e67056efe',
},
{
id: '8baa6530-3fa3-4778-ba11-f675d7d653a4',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
index: 967,
parentId: '3631150a-c6be-4fab-9896-182e67056efe',
},
],
},
}
Foreign keys will be mapped to an entity if it's possible.
Note that circular dependencies will be omitted, and entities won't be generated twice.
A large number of elements in the array makes the generation slower. To improve performance you can pass deep: false in the options, this will disable all deep generation for stubs, e.g.:
const stub = new Stub().createMany(MyEntity, 536, {
deep: false,
});
By passing nullDefaults: true in the options, the stub will return null for any column that is flagged as nullable, e.g. given the entity:
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn('uuid')
public id: string;
@CreateDateColumn()
public createdAt: Date;
@Column({ type: 'varchar', nullable: false })
public name: string;
@Column({ type: 'integer', nullable: true })
public index: number;
@Column({ type: 'boolean', nullable: true })
public isMain: boolean;
}
Then calling:
const stubs = new Stub().createOne(MyEntity, { nullDefaults: true });
Will give:
const stub: MyEntity = {
id: '125a1c28-2938-4996-95f0-d768cbc3c15e',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
name: 'Proin interdum adipiscing vel tortor.',
index: null,
isMain: null
}
You may override a stub generator for specific types, e.g. for string. You should create a new class implementing StubGenerator interface and pass it to Stub:
class MyGenerator implements StubGenerator {
public generateString(_column: ColumnMetadataArgs): string {
return 'overrided!';
}
}
const stub = new Stub(MyGenerator).createOne(MyEntity);
It gives:
const stub: MyEntity = {
id: '125a1c28-2938-4996-95f0-d768cbc3c15e',
createdAt: new Date('2022-10-09T04:43:05.976Z'),
name: 'overrided!',
index: 487,
isMain: true,
}
FAQs
Stubs generator for Typeorm entities
The npm package typeorm-stubs receives a total of 449 weekly downloads. As such, typeorm-stubs popularity was classified as not popular.
We found that typeorm-stubs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.