DD-Path Graph

本文介绍了一种针对命令式语言编写的程序的DD-Path图的概念。DD-Path图是一种有向图,节点代表程序图中的DD-Path,边则表示控制流在相邻DD-Path之间的转移。

    Given a program written in an imperative language, its DD-Path graph  is the directed graph in which nodes are DD-Paths of its program graph, and edges represent control flow between successor DD-Paths.
    for more info, send your questoins to my email.
§
§
  
§

# CurlTools.psm1 - 企业级安全下载模块 $projectRoot = $PSScriptRoot # 从清单文件获取路径配置 $manifest = Test-ModuleManifest -Path (Join-Path $projectRoot "CurlTools.psd1") -ErrorAction Stop $pathConfig = $manifest.PrivateData.PSData.ProjectPaths # 初始化目录路径 $configDir = Join-Path $projectRoot $pathConfig.Config $logDir = Join-Path $projectRoot $pathConfig.Logs $tempDir = Join-Path $projectRoot $pathConfig.Temp $curlBinDir = Join-Path $projectRoot $pathConfig.CurlBin # 目录初始化 foreach ($dir in ($configDir, $logDir, $tempDir, $curlBinDir)) { if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null Write-Verbose "Created directory: $dir" } } function Write-Log { param( [string]$Message, [ValidateSet('Info','Warning','Error','Audit')] [string]$Level = 'Info' ) $logPath = "$logDir\curl_tools_$(Get-Date -Format 'yyyyMMdd').log" $timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' $logEntry = "[$timestamp] [$Level] $Message" Add-Content -Path $logPath -Value $logEntry # 审计级日志额外记录到单独文件 if ($Level -eq 'Audit') { $auditPath = "$logDir\audit_$(Get-Date -Format 'yyyyMMdd').log" Add-Content -Path $auditPath -Value $logEntry } } function Get-CurlPath { <# .SYNOPSIS 获取curl.exe的完整路径 #> try { $curlPath = Join-Path $curlBinDir "curl.exe" if (-not (Test-Path $curlPath)) { throw "curl.exe not found at: $curlPath" } return $curlPath } catch { Write-Log -Message "Get-CurlPath error: $_" -Level 'Error' throw $_ } } function Get-CurlVersion { <# .SYNOPSIS 获取curl版本信息(内部函数) #> try { $curlPath = Get-CurlPath $versionInfo = & $curlPath --version return $versionInfo[0] } catch { Write-Log -Message "Get-CurlVersion error: $_" -Level 'Error' throw $_ } } function Invoke-SecureDownload { <# .SYNOPSIS 执行安全文件下载 #> [CmdletBinding()] param( [Parameter(Mandatory=$true)] [string]$Url, [Parameter(Mandatory=$true)] [string]$OutputPath, [ValidateSet('SHA256','MD5','SHA1')] [string]$HashAlgorithm, [string]$ExpectedHash, [int]$MaxRetry = 3, [int]$MaxDownloadSpeed = 0 ) $activity = "Secure Download" Write-Progress -Activity $activity -Status "Initializing..." $retryCount = 0 $tempFile = $null do { try { # 审计日志 Write-Log -Message "DOWNLOAD INITIATED: $Url => $OutputPath" -Level 'Audit' Write-Log -Message "Starting download (attempt $($retryCount+1)/$MaxRetry): $Url" -Level 'Info' # 域名验证 $domain = ([uri]$Url).Host $configPath = Join-Path $configDir "config.json" if (-not (Test-Path $configPath)) { throw "Config file not found: $configPath" } $config = Get-Content $configPath | ConvertFrom-Json -ErrorAction Stop $isAllowed = $false foreach ($allowed in $config.AllowedDomains) { if ($domain -eq $allowed -or $domain.EndsWith(".$allowed")) { $isAllowed = $true break } } if (-not $isAllowed) { $msg = "Domain blocked by policy: $domain" Write-Log -Message $msg -Level 'Warning' throw $msg } # 输出目录准备 $outputDir = Split-Path $OutputPath -Parent if (-not (Test-Path $outputDir)) { New-Item -Path $outputDir -ItemType Directory -Force | Out-Null Write-Log -Message "Created directory: $outputDir" } # 下载执行 $curlPath = Get-CurlPath $tempFile = Join-Path $tempDir "$([System.IO.Path]::GetRandomFileName()).tmp" $arguments = @( "-L", "--progress-bar", "--fail", "-o", "`"$tempFile`"", "`"$Url`"" ) # 添加限速参数 if ($MaxDownloadSpeed -gt 0) { $arguments += "--limit-rate" $arguments += "$($MaxDownloadSpeed)k" } Write-Progress -Activity $activity -Status "Downloading..." $process = Start-Process -FilePath $curlPath -ArgumentList $arguments ` -NoNewWindow -PassThru -Wait if ($process.ExitCode -ne 0) { throw "Download failed with exit code $($process.ExitCode)" } # 文件验证 if (-not (Test-Path $tempFile)) { throw "Downloaded file not found" } if ((Get-Item $tempFile).Length -eq 0) { throw "Downloaded file is empty" } # 哈希验证 if ($PSBoundParameters.ContainsKey('HashAlgorithm')) { Write-Progress -Activity $activity -Status "Verifying hash..." $actualHash = (Get-FileHash -Path $tempFile -Algorithm $HashAlgorithm).Hash Write-Log -Message "File hash ($HashAlgorithm): $actualHash" -Level 'Info' if ($PSBoundParameters.ContainsKey('ExpectedHash') -and $actualHash -ne $ExpectedHash) { $msg = "Hash verification failed! Expected: $ExpectedHash, Actual: $actualHash" Write-Log -Message $msg -Level 'Error' throw $msg } } # 最终文件移动 Move-Item -Path $tempFile -Destination $OutputPath -Force Write-Log -Message "Download completed: $OutputPath" -Level 'Info' # 在模块清单文件 (CurlTools.psd1) 中添加 FunctionsToExport = @('Get-CurlPath', 'Get-CurlVersion', 'Invoke-SecureDownload') # 在模块主体中实现 Get-CurlVersion function Get-CurlVersion { $curlPath = Get-CurlPath try { $result = & $curlPath --version 2>&1 return ($result | Select-Object -First 1).Trim() } catch { Write-Error "Failed to get curl version: $_" return $null } } # 添加配置注入点 $script:ModuleConfig = @{ AllowedDomains = @("example.com", "github.com") MaxDownloadSpeed = 1024 } function Set-ModuleConfig { param( [hashtable]$Config ) $script:ModuleConfig = $Config } Write-Log -Message "DOWNLOAD COMPLETED: $Url => $OutputPath" -Level 'Audit' return $true } catch { $retryCount++ Write-Log -Message "Download attempt $retryCount failed: $_" -Level 'Warning' if ($retryCount -ge $MaxRetry) { Write-Log -Message "Max retries reached for: $Url" -Level 'Error' throw "Download failed after $MaxRetry attempts: $_" } # 等待指数退避时间 $delay = [Math]::Pow(2, $retryCount) Write-Progress -Activity $activity -Status "Retrying in $delay seconds..." Start-Sleep -Seconds $delay } finally { if ($null -ne $tempFile -and (Test-Path $tempFile)) { Remove-Item $tempFile -Force -ErrorAction SilentlyContinue } } } while ($retryCount -lt $MaxRetry) } # 导出公共函数 Export-ModuleMember -Function 'Get-CurlPath', 'Invoke-SecureDownload'
08-15
server: port: 8802 # tomcat: # uriEncoding: "UTF-8" # remoteip: # protocol-header-https-value: "https" # remote-ip-header: "RemoteIpValve" # protocol-header: "X-Forwarded-Proto" servlet: context-path: /gateway cors: allowedOrigin: "*" management: endpoints: web: exposure: include: "*" spring: data: redis: client-type: lettuce # 使用响应式客户端 config: import: - "nacos:uap-gateway-test.properties?group=latest&server-addr=uap.qctc.com:8800" - "nacos:common-config.properties?group=latest&server-addr=uap.qctc.com:8800" application: name: uap-gateway main: web-application-type: reactive allow-bean-definition-overriding: true profiles: active: test # group: # latest: [ test ] # 使用数组形式定义包含的profile # 可添加其他组: # production: [prod, metrics] resources: add-mappings: true cloud: config: profile: dev discovery: enabled: true service-id: zhny-config bus: enabled: false trace: enabled: false nacos: # 增加全局日志禁用参数(关键修复) bootstrap: log: enabled: false # 关闭Nacos启动时的日志系统初始化 logging: config: false # 禁用Nacos内部日志配置 naming: false remote: false default: config: enabled: false discovery: server-addr: uap.qctc.com:8801 #uap.qctc.com:8900 11.14.30.16:8848 group: latest config: server-addr: uap.qctc.com:8801 file-extension: properties namespace: public group: latest name: uap-gateway # Data ID prefix: uap-gateway # shared-configs: # - data-id: common-config.properties # group: latest # refresh: true import-check: enabled: false # 禁用导入检查(可选) gateway: # 全局连接池与超时配置 httpclient: retry: false # 全局关闭重试 # 允许特殊字符 relaxed-cookies: true pool: max-connections: 2000 # 最大总连接数 [2,5](@ref) max-idle-time: 50000ms # 连接空闲超时 connect-timeout: 50000 # 连接超时(毫秒)[2](@ref) response-timeout: 50000 # 响应超时(毫秒)[2](@ref) protool: h2c keepalive: true # 全局跨域配置(按需启用) globalcors: add-to-simple-url-handler-mapping: true cors-configurations: '[/**]': allowed-origins: "*" allow-credentials: false # 保持凭证携带 allowed-methods: "GET,POST" allowedMethods: "GET,POST" allowed-headers: "*" max-age: 3600 # 预检请求缓存时间 # 全局默认过滤器:移除 /api 前缀 [1,4](@ref) default-filters: - RewritePath=/api/(?<segment>.*), /$\{segment} discovery: locator: enabled: true # 开启从注册中心动态创建路由的功能,利用微服务名进行路由 routes: - id: gateway_self_api uri: no://op # 特殊标记,表示不转发 predicates: - Path=/gateway/api/isLicenseOverdue filters: - SetPath=/ # 内置过滤器(仅作占位符) # - id: gateway_prefix_route # uri: lb://uap-base # predicates: # - Path=/gateway/api/uap/** # filters: # - StripPrefix=2 # 移除 /gateway/api,保留 /uap/... # 1. uap-base 服务 - id: base uri: lb://uap-base predicates: - Path=/gateway/api/uap/** filters: - StripPrefix=2 - id: customer uri: lb://uap-base predicates: - Path=/gateway/api/customer/** filters: - StripPrefix=2 # 2. zhny-publish-test 服务 - id: market uri: lb://zhny-publish-test predicates: - Path=/gateway/api/market/** filters: - StripPrefix=2 - id: cmsservice uri: lb://zhny-publish-test predicates: - Path=/gateway/api/cmsservice/** filters: - StripPrefix=2 - id: sns uri: lb://zhny-publish-test predicates: - Path=/gateway/api/sns/** filters: - StripPrefix=2 - id: trade uri: lb://zhny-publish-test predicates: - Path=/gateway/api/trade/** filters: - StripPrefix=2 - id: settle uri: lb://zhny-publish-test predicates: - Path=/gateway/api/settle/** filters: - StripPrefix=2 - id: vpp uri: lb://zhny-publish-test predicates: - Path=/gateway/api/vpp/** filters: - StripPrefix=2 - id: nbxy uri: lb://zhny-publish-test predicates: - Path=/gateway/api/nbxy/** filters: - StripPrefix=2 - id: pla uri: lb://zhny-publish-test predicates: - Path=/gateway/api/pla/** filters: - StripPrefix=2 # 3. 其他独立服务 - id: analysis # zhny-esf uri: lb://zhny-publish-test predicates: - Path=/gateway/api/analysis/** filters: - StripPrefix=2 - id: dta # zhny-dta uri: lb://zhny-dta predicates: - Path=/gateway/api/dta/** filters: - StripPrefix=2 - id: crd # zhny-crd uri: lb://zhny-crd predicates: - Path=/gateway/api/crd/** filters: - StripPrefix=2 - id: hnsd # zhny-hnsd uri: lb://zhny-hnsd predicates: - Path=/gateway/api/hnsd/** filters: - StripPrefix=2 - id: grc # zhny-grc uri: lb://zhny-grc predicates: - Path=/gateway/api/grc/** filters: - StripPrefix=2 - id: ecarbon # zhny-ecarbon uri: lb://zhny-ecarbon predicates: - Path=/gateway/api/ecarbon/** filters: - StripPrefix=2 - id: rpt # zhny-rpt uri: lb://zhny-rpt predicates: - Path=/gateway/api/rpt/** filters: - StripPrefix=2 - id: gdt # zhny-gdt uri: lb://zhny-gdt predicates: - Path=/gateway/api/gdt/** filters: - StripPrefix=2 - id: ems # zhny-ems uri: lb://zhny-ems predicates: - Path=/gateway/api/ems/** filters: - StripPrefix=2 - id: ecm # zhny-ecm uri: lb://zhny-ecm predicates: - Path=/gateway/api/ecm/** filters: - StripPrefix=2 - id: hbvpp # zhny-hbvpp uri: lb://zhny-hbvpp predicates: - Path=/gateway/api/hbvpp/** filters: - StripPrefix=2 - id: gcd # zhny-gcd uri: lb://zhny-publish-test predicates: - Path=/gateway/api/gcd/** filters: - StripPrefix=2 - id: hbdkclient # zhny-hbdkclient uri: lb://zhny-hbdkclient predicates: - Path=/gateway/api/hbdkclient/** filters: - StripPrefix=2 - id: fhjhjy # zhny-fhjhjy uri: lb://zhny-fhjhjy predicates: - Path=/gateway/api/fhjhjy/** filters: - StripPrefix=2 - id: sdpxvpp # sd-sdpxvpp uri: lb://sd-sdpxvpp predicates: - Path=/gateway/api/sdpxvpp/** filters: - StripPrefix=2 - id: dts # zhny-dts uri: lb://zhny-dts predicates: - Path=/gateway/api/dts/** filters: - StripPrefix=2 - id: rec # zhny-rec uri: lb://zhny-rec predicates: - Path=/gateway/api/rec/** filters: - StripPrefix=2 - id: ptc # zhny-ptc uri: lb://zhny-ptc predicates: - Path=/gateway/api/ptc/** filters: - StripPrefix=2 - id: lmp # zhny-lmp uri: lb://zhny-publish-test predicates: - Path=/gateway/api/lmp/** filters: - StripPrefix=2 eureka: client: fetch-registry: true # 必须显式启用 register-with-eureka: true # 必须显式启用 healthcheck: enabled: false serviceUrl: defaultZone: http://qctczhny:QCTCzhny6608!@uap.qctc.com:8800/eureka instance: metadata-map: management: context-path: ${server.servlet.context-path}/actuator prefer-ip-address: true instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} lease-renewal-interval-in-seconds: 2 #续约间隔 lease-expiration-duration-in-seconds: 4 #租约寿命 #status-page-url: http://${spring.cloud.client.ip-address}:${server.port}/api/doc.html health-check-url-path: ${server.servlet.context-path}/actuator/health #swagger: # enabled: true # name: QCTC统一开发平台 #api名称 # description: QCTC统一开发平台接口文档说明 #api描述 # termsOfServiceUrl: http://uap.qctc.com:8802${server.servlet.context-path} # developer: QCTC #api开发 # version: 3.0.0 #api开发 # basic: # enable: true # username: qctc # password: qctcadmin6608 feign: # 启用 Resilience4j circuitbreaker: enabled: true group: enabled: true httpclient: enabled: false okhttp: enabled: true compression: request: enabled: true mime-types: text/html,text/xml,text/plain,application/xml,application/json response: enabled: true # 定义客户端超时 client: config: default: # 全局默认配置 connectTimeout: 5000 # 连接超时(ms) readTimeout: 10000 # 读取超时(ms) # 绑定熔断器和超时器 resilience4jCircuitBreakerName: default resilience4jTimelimiterName: default ####超时配置#### resilience4j: circuitbreaker: instances: default: # 默认熔断器配置(作用于所有 Feign 调用) failureRateThreshold: 50 # 失败率阈值% minimumNumberOfCalls: 10 # 最小调用次数 slidingWindowType: COUNT_BASED slidingWindowSize: 10 # 统计窗口大小 waitDurationInOpenState: 10s # 熔断持续时间 timelimiter: instances: default: timeoutDuration: 5s # 单次调用超时时间 # 日志 logging: file: name: /usr/qctcapps/gateway/data/${spring.application.name}/debug.log #/usr/qctcapps/publish_test pattern: file: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID}){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx" level: root: info com.qctc.uap: info # com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder: DEBUG # org.springframework.core.env.PropertySourcesPropertyResolver: DEBUG # org.springframework.cloud.gateway.filter: TRACE # reactor.netty.http.client: DEBUG 配置有问题吗
最新发布
09-02
PS C:\Users\Administrator> function Get-CurlPath { >> # 从配置获取curl路径 >> $configPath = "E:\CurlTools\Config\config.json" >> if (-not (Test-Path $configPath)) { >> throw "Config file not found: $configPath" >> } >> >> $config = Get-Content $configPath | ConvertFrom-Json >> $curlPath = Join-Path $config.CurlPath "curl.exe" >> >> if (-not (Test-Path $curlPath)) { >> throw "curl.exe not found! Check path: $curlPath" >> } >> >> return $curlPath >> } >> >> function Get-CurlVersion { >> # 获取curl版本信息 >> $curlPath = Get-CurlPath >> $version = & $curlPath --version | Select-Object -First 1 >> return $version >> } >> >> function Invoke-SecureDownload { >> param( >> [Parameter(Mandatory=$true)] >> [string]$Url, >> >> [Parameter(Mandatory=$true)] >> [string]$OutputPath >> ) >> >> # 检查域名是否允许 >> $domain = ([System.Uri]$Url).Host >> $configPath = "E:\CurlTools\Config\config.json" >> >> if (-not (Test-Path $configPath)) { >> throw "Config file not found: $configPath" >> } >> >> $config = Get-Content $configPath | ConvertFrom-Json >> >> # 增强域名检查逻辑 >> if (-not $config.AllowedDomains) { >> throw "No allowed domains configured!" >> } >> >> if ($domain -notin $config.AllowedDomains) { >> throw "Domain not allowed: $domain! Allowed domains: $($config.AllowedDomains -join ', ')" >> } >> >> # 确保输出目录存在 >> $outputDir = Split-Path $OutputPath -Parent >> if (-not (Test-Path $outputDir)) { >> New-Item -Path $outputDir -ItemType Directory -Force | Out-Null >> } >> >> # 执行下载 >> $curlPath = Get-CurlPath >> & $curlPath -L -o $OutputPath $Url >> >> if ($LASTEXITCODE -ne 0) { >> throw "Download failed! Error code: $LASTEXITCODE" >> } >> >> Write-Host "Download successful: $OutputPath" -ForegroundColor Green >> } >> PS C:\Users\Administrator> { >> "CurlPath": "E:\\CurlTools\\CurlBin", >> "AllowedDomains": [ >> "example.com", >> "github.com", >> "microsoft.com" >> ] >> } >> 所在位置 行:2 字符: 15 + "CurlPath": "E:\\CurlTools\\CurlBin", + ~ 表达式或语句中包含意外的标记“:”。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken PS C:\Users\Administrator> # 设置UTF-8编码 >> [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 >> $OutputEncoding = [System.Text.Encoding]::UTF8 >> chcp 65001 | Out-Null >> >> # 添加模块路径 >> $modulePath = "E:\CurlTools\Modules" >> if ($env:PSModulePath -notlike "*$modulePath*") { >> $env:PSModulePath += ";$modulePath" >> } >> >> # 自动加载模块 >> Import-Module CurlTools -Force -ErrorAction SilentlyContinue >> PS C:\Users\Administrator> graph TD >> A[PowerShell会话] --> B[$PROFILE] >> B --> C[自动加载模块] >> C --> D[CurlTools模块] >> D --> E[Get-CurlPath] >> D --> F[Get-CurlVersion] >> D --> G[Invoke-SecureDownload] >> A --> H[配置文件] >> H --> I[config.json] >> H --> J[日志文件] >> G --> K[域名检查] >> G --> L[安全下载] >> K --> M[AllowedDomains验证] >> L --> N[curl.exe执行] >> graph : 无法将“graph”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 + graph TD + ~~~~~ + CategoryInfo : ObjectNotFound: (graph:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException A[PowerShell会话] : 无法将“A[PowerShell会话]”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:2 字符: 5 + A[PowerShell会话] --> B[$PROFILE] + ~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (A[PowerShell会话]:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException B : 无法将“B”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:3 字符: 5 + B --> C[自动加载模块] + ~ + CategoryInfo : ObjectNotFound: (B:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException C : 无法将“C”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:4 字符: 5 + C --> D[CurlTools模块] + ~ + CategoryInfo : ObjectNotFound: (C:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException D : 无法将“D”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:5 字符: 5 + D --> E[Get-CurlPath] + ~ + CategoryInfo : ObjectNotFound: (D:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException D : 无法将“D”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:6 字符: 5 + D --> F[Get-CurlVersion] + ~ + CategoryInfo : ObjectNotFound: (D:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException D : 无法将“D”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:7 字符: 5 + D --> G[Invoke-SecureDownload] + ~ + CategoryInfo : ObjectNotFound: (D:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException A : 无法将“A”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:8 字符: 5 + A --> H[配置文件] + ~ + CategoryInfo : ObjectNotFound: (A:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Get-History : 无法绑定参数“Count”。无法将值“I[config.json]”转换为类型“System.Int32”。错误:“输入字符串的格式不正确。” 所在位置 行:9 字符: 11 + H --> I[config.json] + ~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-History],ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetHistoryCommand Get-History : 无法绑定参数“Count”。无法将值“J[日志文件]”转换为类型“System.Int32”。错误:“输入字符串的格式不正确。 ” 所在位置 行:10 字符: 11 + H --> J[日志文件] + ~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-History],ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetHistoryCommand G : 无法将“G”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:11 字符: 5 + G --> K[域名检查] + ~ + CategoryInfo : ObjectNotFound: (G:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException G : 无法将“G”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:12 字符: 5 + G --> L[安全下载] + ~ + CategoryInfo : ObjectNotFound: (G:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException K : 无法将“K”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:13 字符: 5 + K --> M[AllowedDomains验证] + ~ + CategoryInfo : ObjectNotFound: (K:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException L : 无法将“L”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:14 字符: 5 + L --> N[curl.exe执行] + ~ + CategoryInfo : ObjectNotFound: (L:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator> # 在模块顶部添加日志函数 >> function Write-Log { >> param( >> [string]$Message, >> [ValidateSet('Info','Warning','Error')] >> [string]$Level = 'Info' >> ) >> >> $logPath = "E:\CurlTools\Logs\curl_tools_$(Get-Date -Format 'yyyyMMdd').log" >> $logEntry = "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] [$Level] $Message" >> >> Add-Content -Path $logPath -Value $logEntry >> } >> >> # 在关键位置添加日志记录 >> function Invoke-SecureDownload { >> # ... 其他代码 ... >> >> Write-Log -Message "Starting download: $Url" -Level 'Info' >> >> try { >> # ... 域名检查 ... >> Write-Log -Message "Domain allowed: $domain" >> >> # ... 执行下载 ... >> Write-Log -Message "Download completed: $OutputPath" >> } >> catch { >> Write-Log -Message "Download failed: $_" -Level 'Error' >> throw $_ >> } >> } >> PS C:\Users\Administrator> $url = "https://subdomain.example.com/path" >> $domain = ([System.Uri]$url).Host # 返回 "subdomain.example.com" >> PS C:\Users\Administrator> if (-not (Test-Path $config.CurlPath)) { >> throw "CurlPath directory not found: $($config.CurlPath)" >> } >> Test-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。 所在位置 行:1 字符: 21 + if (-not (Test-Path $config.CurlPath)) { + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Test-Path],ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom mand PS C:\Users\Administrator>
08-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值