mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-19 01:30:42 -07:00
Disallow and suppress unsafe assignment (#19736)
This commit is contained in:
committed by
GitHub
parent
b746524a1b
commit
58d637f919
@@ -23,6 +23,7 @@ export function resolveEnvVarsInString(
|
||||
): string {
|
||||
const envVarRegex = /\$(?:(\w+)|{([^}]+)})/g; // Find $VAR_NAME or ${VAR_NAME}
|
||||
return value.replace(envVarRegex, (match, varName1, varName2) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const varName = varName1 || varName2;
|
||||
if (customEnv && typeof customEnv[varName] === 'string') {
|
||||
return customEnv[varName];
|
||||
|
||||
@@ -78,6 +78,7 @@ export const getLatestGitHubRelease = async (
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const releaseTag = (await response.json()).tag_name;
|
||||
if (!releaseTag) {
|
||||
throw new Error(`Response did not include tag_name field`);
|
||||
|
||||
@@ -29,6 +29,7 @@ export function tryParseJSON(input: string): object | null {
|
||||
if (!checkInput(input)) return null;
|
||||
const trimmed = input.trim();
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const parsed = JSON.parse(trimmed);
|
||||
if (parsed === null || typeof parsed !== 'object') {
|
||||
return null;
|
||||
|
||||
@@ -38,6 +38,7 @@ export class PersistentState {
|
||||
const filePath = this.getPath();
|
||||
if (fs.existsSync(filePath)) {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.cache = JSON.parse(content);
|
||||
} else {
|
||||
this.cache = {};
|
||||
|
||||
@@ -23,6 +23,7 @@ export async function readStdin(): Promise<string> {
|
||||
|
||||
const onReadable = () => {
|
||||
let chunk;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
while ((chunk = process.stdin.read()) !== null) {
|
||||
if (pipedInputTimerId) {
|
||||
clearTimeout(pipedInputTimerId);
|
||||
|
||||
@@ -254,6 +254,7 @@ export const getAllSessionFiles = async (
|
||||
async (file): Promise<SessionFileEntry> => {
|
||||
const filePath = path.join(chatsDir, file);
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const content: ConversationRecord = JSON.parse(
|
||||
await fs.readFile(filePath, 'utf8'),
|
||||
);
|
||||
@@ -498,6 +499,7 @@ export class SessionSelector {
|
||||
const sessionPath = path.join(chatsDir, sessionInfo.fileName);
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const sessionData: ConversationRecord = JSON.parse(
|
||||
await fs.readFile(sessionPath, 'utf8'),
|
||||
);
|
||||
|
||||
@@ -371,6 +371,7 @@ export function setPendingSettingValue(
|
||||
pendingSettings: Settings,
|
||||
): Settings {
|
||||
const path = key.split('.');
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const newSettings = JSON.parse(JSON.stringify(pendingSettings));
|
||||
setNestedValue(newSettings, path, value);
|
||||
return newSettings;
|
||||
|
||||
Reference in New Issue
Block a user