
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
elastic-ecs
Advanced tools
This wraps up the Elastic Common Schema into strict Typescript types by parsing the official ECS schema document. Since this library is pure types and a strict reflection of ECS, the version is pinned to the ECS version itself, currently at version 8.4. You can also clone this repo to build against a given ECS version yourself.
Run:
npm install elastic-ecs
This NPM package's version is pinned to the associated ECS version, so version 8.4.0 of this lib would represent ECS version 8.4, for example.
Any patch or minor updates will be reflected with appending -[a-z]* to the ECS semver version.
import { EcsFields, EcsTree } from 'elastic-ecs';
interface MyBasicEcsEvent extends EcsFields {
[EcsFields["event.created"]]: new Date(),
[EcsFields["event.action"]]: 'page-viewed',
[EcsFields["event.kind"]]: 'event',
[EcsFields["event.category"]]: ['myCat'], // Causes Compile error, myCat is not a valid value!
}
By defining your own Schema, you can get lots of free type safety when both defining your custom fields on top of ECS fields and when defining individual events:
import { NewEventType, NewSchema, EcsFields } from 'elaastic-ecs'
// All the custom fields you ever put in events should go here
interface MyCustomFields {
// Optional fields on some events
'attempts.count'?: number,
// Required fields on ALL events
'customer.id': string,
}
// Make all ECS fields available, another good option could be EcsCoreFields if you don't need extended fields
type MyEcsFieldNames = EcsFields & {
// Required ECS fields
'@timestamp': Date,
'event.action': string,
}
// Define my schema based on my custom fields and the ECS fields I have available
type MySchema = NewSchema<MyCustomFields, MyEcsFieldNames>
// My Event Types
// Verbose schema, spell out the field names AND types
type MyLogoutEvent = NewEventSchema<MySchema, {
'@timestamp': Date,
'event.action': 'User Logout',
'customer.id': string
// Optional fields
'event.category'?: 'authentication'[],
}>
// Shorthand schema, don't need to include fields' types
type MyLoginEvent = NewEventType<MySchema,
'@timestamp' | 'event.action' | 'customer.id', // Required Event Fields
'event.category' | 'attempts.count', // Optional Event Fields
{'event.action': 'User Login'} // Per-Event schema type narrowing
>
const loginEvent: MyLoginEvent = {
'event.action': 'User Login',
'@timestamp': new Date(),
'attempts.count': 1,
'customer.id': '123',
};
const logoutEvent: MyLogoutEvent = {
'@timestamp': new Date(),
'event.action': 'User Logout',
'customer.id': '123',
};
I may be too lazy to keep up-to-date with the latest ECS version on a weekly or monthly basis. If you require the latest and greatest now, please run the automated build process below and send me a pull request! This'll probably be motivating enough to get me off my rear.
package.json to match the ECS version you want to build against, plus an extra zero such as 8.4.0.package.json under the build-types script and make sure it matches the version from step 3, but without the last number, ex. 8.4.npm install to install dependencies.npm run build to build the type definitions.FAQs
Typescript type defs for ECS Schema
We found that elastic-ecs 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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.