Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/entry-points.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/config/db-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export function mergeDefaultSetupAndUserConfigs(
{
invalidKeys: schemaCheckResult.invalidKeys,
},
["internal-error"],
Comment thread
mbg marked this conversation as resolved.
),
);
}
Expand All @@ -140,6 +141,7 @@ export function mergeDefaultSetupAndUserConfigs(
{
unrecognisedKeys: schemaCheckResult.unknownKeys,
},
["internal-error"],
),
);
}
Expand Down
71 changes: 52 additions & 19 deletions src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,45 @@ import { Language } from "./languages";
import { getActionsLogger } from "./logging";
import { getCodeQLDatabasePath } from "./util";

/** Represents a diagnostic message for the tool status page, etc. */
export interface DiagnosticMessage {
/**
* Known tags for diagnostics. There is currently only "internal-error",
* but others may be added in the future.
*/
export type DiagnosticTag = "internal-error";

/** Optional information about the origin of a diagnostic. */
export type DiagnosticSourceOptions = {
/**
* Name of the CodeQL extractor. This is used to identify which tool component the reporting
* descriptor object should be nested under in SARIF.
*/
extractorName?: string;
/** An array of tags for the diagnostic. */
tags?: DiagnosticTag[];
};

/** Represents information about the origin of a diagnostic. */
export type DiagnosticSource = {
/**
* An identifier under which it makes sense to group this diagnostic message.
* This is used to build the SARIF reporting descriptor object.
*/
id: string;
/** Display name for the ID. This is used to build the SARIF reporting descriptor object. */
name: string;
} & DiagnosticSourceOptions;

/**
* Represents a diagnostic message for the tool status page, etc.
*
* Unlike {@link DiagnosticMessage}, properties which can automatically
* be populated are optional in this type.
*/
export type DiagnosticMessageOptions = {
/** ISO 8601 timestamp */
timestamp: string;
source: {
/**
* An identifier under which it makes sense to group this diagnostic message.
* This is used to build the SARIF reporting descriptor object.
*/
id: string;
/** Display name for the ID. This is used to build the SARIF reporting descriptor object. */
name: string;
/**
* Name of the CodeQL extractor. This is used to identify which tool component the reporting
* descriptor object should be nested under in SARIF.
*/
extractorName?: string;
};
timestamp?: string;
/** Information about the origin of the diagnostic. */
source?: DiagnosticSourceOptions;
/** GitHub flavored Markdown formatted message. Should include inline links to any help pages. */
markdownMessage?: string;
/** Plain text message. Used by components where the string processing needed to support Markdown is cumbersome. */
Expand Down Expand Up @@ -53,7 +74,15 @@ export interface DiagnosticMessage {
};
/** Structured metadata about the diagnostic message */
attributes?: { [key: string]: any };
}
};

/** Represents a diagnostic message for the tool status page, etc. */
export type DiagnosticMessage = DiagnosticMessageOptions & {
/** ISO 8601 timestamp */
timestamp: string;
/** Information about the origin of the diagnostic. */
source: DiagnosticSource;
};

/** Represents a diagnostic message that has not yet been written to the database. */
interface UnwrittenDiagnostic {
Expand Down Expand Up @@ -90,7 +119,7 @@ let diagnosticCounter = 0;
export function makeDiagnostic(
id: string,
name: string,
data: Partial<DiagnosticMessage> | undefined = undefined,
data: DiagnosticMessageOptions | undefined = undefined,
): DiagnosticMessage {
return {
...data,
Expand Down Expand Up @@ -243,6 +272,7 @@ export function makeTelemetryDiagnostic(
id: string,
name: string,
attributes: { [key: string]: any },
tags?: DiagnosticTag[],
): DiagnosticMessage {
return makeDiagnostic(id, name, {
attributes,
Expand All @@ -251,5 +281,8 @@ export function makeTelemetryDiagnostic(
statusPage: false,
telemetry: true,
},
source: {
tags,
},
});
}
Loading