{"record":{"id":"2778403a90eef7b8","repo":"urbanadventurer/WhatWeb","slug":"error-you-do-not-have-permission-to-view-target","errorCode":null,"errorMessage":"Error: You do not have permission to view #{@target}","messagePattern":"Error: You do not have permission to view #(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/target.rb","lineNumber":188,"sourceCode":"\n  def initialize(target = nil, redirect_counter = 0)\n    @target = target\n    @redirect_counter = redirect_counter\n    @headers = {}\n    @http_options = { method: 'GET' }\n    #\t\t@status=0\n\n    @is_url = if @target =~ /^http[s]?:\\/\\//\n                true\n              else\n                false\n              end\n\n    if File.exist?(@target)\n      @is_file = true\n      raise \"Error: #{@target} is a directory\" if File.directory?(@target)\n      if File.readable?(@target) == false\n        raise \"Error: You do not have permission to view #{@target}\"\n      end\n    else\n      @is_file = false\n    end\n\n    if is_url?\n      @uri = URI.parse(Addressable::URI.encode(@target))\n\n      # is this taking control away from the user?\n      # [400] http://www.alexa.com  [200] http://www.alexa.com/\n      @uri.path = '/' if @uri.path.empty?\n    else\n      # @uri=URI.parse(\"file://\"+@target)\n      @uri = URI.parse('')\n    end\n  end\n\n  def open","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/urbanadventurer/WhatWeb/blob/d279d93042d034f3fd29d5a893d44ccc0595d3f8/lib/target.rb#L170-L206","documentation":"Raised in Target#initialize (lib/target.rb:188) when the target path exists but the process lacks read permission (File.readable? is false). WhatWeb cannot open the file to scan it, so target construction fails with a permission message naming the target.","triggerScenarios":"Target.new('/path/to/file') where File.exist? is true but File.readable? is false — e.g. root-owned file with 0600, files under another user's home, or restrictive ACLs when running whatweb as an unprivileged user.","commonSituations":"Running whatweb without sudo against root-owned capture/target files; files created by another user with default umask 0077; mounted volumes or containers dropping read permissions; scanning a saved page owned by a service account.","solutions":["chmod/chown the file so the running user can read it, or run whatweb as a user with access (sudo)","Copy the file to a readable location before scanning","Verify with ls -l / test -r \"$TARGET\" before running","If in a container, mount the file read-only with correct uid/gid mapping"],"exampleFix":"# before\nwhatweb /root/captures/site.html\n# after\nsudo whatweb /root/captures/site.html\n# or\nchmod +r /root/captures/site.html","handlingStrategy":"validation","validationCode":"target = '/path/to/file'\nraise 'unreadable target' unless File.readable?(target)\n# shell: test -r \"$TARGET\" || sudo whatweb \"$TARGET\"","typeGuard":"def readable_file?(t)\n  File.file?(t) && File.readable?(t)\nend","tryCatchPattern":"begin\n  target = Target.new(path)\nrescue RuntimeError => e\n  raise unless e.message.start_with?('Error: You do not have permission')\n  STDERR.puts \"permission denied on #{path}; try sudo or chmod\"\nend","preventionTips":["Run test -r on target files before scanning","Check ownership/umask of files produced by other users or services","Copy root-owned files to a readable location as a routine step","Map uids correctly when mounting files into containers"],"tags":["filesystem","permissions","file-access"],"backgroundTag":"permission-denied","analyzedSha":"d279d93042d034f3fd29d5a893d44ccc0595d3f8","analyzedAt":"2026-09-15T13:51:42.453Z","contentChangedAt":"2026-09-15T13:51:42.453Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}