Inno setup Inno设置-抑制“;设置命令行:";日志条目
我们使用Inno安装程序(版本5.4.2)作为打包工具来生成安装程序。我们正在传递一些密码值作为命令行参数。在Inno安装程序中,所有命令行参数都会使用“Setup command line:”条目自动登录到安装日志中。是禁止“设置命令行”登录日志的任何方法。否。您只能禁用整个日志记录。以下是本报告相关部分的摘录: 正如您所看到的,在过程调用命令行尾部之前没有任何条件,并且过程本身不包含过滤某些日志消息的方法。因此,目前防止这种潜在安全问题的唯一方法是禁用整个日志记录Inno setup Inno设置-抑制“;设置命令行:";日志条目,inno-setup,Inno Setup,我们使用Inno安装程序(版本5.4.2)作为打包工具来生成安装程序。我们正在传递一些密码值作为命令行参数。在Inno安装程序中,所有命令行参数都会使用“Setup command line:”条目自动登录到安装日志中。是禁止“设置命令行”登录日志的任何方法。否。您只能禁用整个日志记录。以下是本报告相关部分的摘录: 正如您所看到的,在过程调用命令行尾部之前没有任何条件,并且过程本身不包含过滤某些日志消息的方法。因此,目前防止这种潜在安全问题的唯一方法是禁用整个日志记录 由于这可能是一个安全问题,
由于这可能是一个安全问题,我建议您提交一份功能请求报告。作为替代方案,您可以要求用户通过命令行提供INI文件: config.ini 命令行调用 帕斯卡语 请注意,其中一些未经测试,请自行承担使用风险
function CommandLineSwitchIsPresent(Param : String): Boolean;
var
i: Integer;
begin
Result := False;
if not StartsWith('/', Param) then
begin
Param := '/' + Param;
end;
for i:= 0 to ParamCount do
begin
if (CompareText(Param, ParamStr(i)) = 0)
or StartsWith(Param + '=', ParamStr(i)) then
begin
Result := True;
break;
end;
end;
end;
function GetCommandlineParam(Param: String; var OutStr: String): Boolean;
var
ParamNameAndValue: String;
i: Integer;
j: Integer;
begin
Result := False;
Param := Param + '=';
if not StartsWith('/', Param) then
begin
Param := '/' + Param;
end;
for i := 0 to ParamCount do
begin
ParamNameAndValue := ParamStr(i);
if StartsWith(AnsiUppercase(Param), AnsiUppercase(ParamNameAndValue)) then
begin
for j := 0 to Length(ParamNameAndValue) do
begin
if j > Length(Param) then
begin
OutStr := OutStr + ParamNameAndValue[j];
end;
end;
Result := True;
break;
end;
end;
end;
function GetConfig(Section: String; Key: String; ConfigFile: String): String;
begin
if IniKeyExists('credentials', Key, ConfigFile) then
begin
Result := GetIniString('credentials', Key, '', ConfigFile);
end
else begin
RaiseException(
Format(
'%s key not found in [%s] section in %s', [Key, Section, ConfigFile]
);
end;
end;
var
_gConfigFile: String;
procedure DoStuffWithPassword();
var
Username: String;
Password: String;
ShortPath: String;
ExpandedPath: String;
begin
if not GetCommandlineParam('CONFIGFILE', ShortPath) then
begin
RaiseException('CONFIGFILE parameter is required!');
end;
// Go from relative path to absolute
ExpandedPath := ExpandFileName(ShortPath);
if FileExists(ExpandedPath) then
begin
_gConfigFile := ExpandedPath;
end
else begin
RaiseException('CONFIGFILE file ' + ShortPath + ' not found!');
end;
Username := GetConfig('credentials', 'username', _gConfigFile);
Password := GetConfig('credentials', 'password', _gConfigFile);
end;
[credentials]
username=foo
password=bar
setup.exe /CONFIGFILE=config.ini
function CommandLineSwitchIsPresent(Param : String): Boolean;
var
i: Integer;
begin
Result := False;
if not StartsWith('/', Param) then
begin
Param := '/' + Param;
end;
for i:= 0 to ParamCount do
begin
if (CompareText(Param, ParamStr(i)) = 0)
or StartsWith(Param + '=', ParamStr(i)) then
begin
Result := True;
break;
end;
end;
end;
function GetCommandlineParam(Param: String; var OutStr: String): Boolean;
var
ParamNameAndValue: String;
i: Integer;
j: Integer;
begin
Result := False;
Param := Param + '=';
if not StartsWith('/', Param) then
begin
Param := '/' + Param;
end;
for i := 0 to ParamCount do
begin
ParamNameAndValue := ParamStr(i);
if StartsWith(AnsiUppercase(Param), AnsiUppercase(ParamNameAndValue)) then
begin
for j := 0 to Length(ParamNameAndValue) do
begin
if j > Length(Param) then
begin
OutStr := OutStr + ParamNameAndValue[j];
end;
end;
Result := True;
break;
end;
end;
end;
function GetConfig(Section: String; Key: String; ConfigFile: String): String;
begin
if IniKeyExists('credentials', Key, ConfigFile) then
begin
Result := GetIniString('credentials', Key, '', ConfigFile);
end
else begin
RaiseException(
Format(
'%s key not found in [%s] section in %s', [Key, Section, ConfigFile]
);
end;
end;
var
_gConfigFile: String;
procedure DoStuffWithPassword();
var
Username: String;
Password: String;
ShortPath: String;
ExpandedPath: String;
begin
if not GetCommandlineParam('CONFIGFILE', ShortPath) then
begin
RaiseException('CONFIGFILE parameter is required!');
end;
// Go from relative path to absolute
ExpandedPath := ExpandFileName(ShortPath);
if FileExists(ExpandedPath) then
begin
_gConfigFile := ExpandedPath;
end
else begin
RaiseException('CONFIGFILE file ' + ShortPath + ' not found!');
end;
Username := GetConfig('credentials', 'username', _gConfigFile);
Password := GetConfig('credentials', 'password', _gConfigFile);
end;