GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add DOCTYPE, header and similar list style as that of python's by li6in9muyou · Pull Request #106 · projectdiscovery/simplehttpserver

Conversation

@li6in9muyou

@li6in9muyou li6in9muyou commented Mar 14, 2023

Copy link
Copy Markdown
Contributor

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ehsandeep and others added 7 commits April 18, 2022 18:24
@ehsandeep
Merge pull request projectdiscovery#74 from projectdiscovery/dev
d70d482
0.0.5 Release
li6in9muyou
feat: use same page style as python's
e1c0954
li6in9muyou
test: pythonliststyle_test.go
971d31e
li6in9muyou
refactor: make it clearer that we surround original html with proper …
2a8f8fd
…header and footer
li6in9muyou
refactor: explain what these lines do
ffb26a3
li6in9muyou
fix: html title is not updated as URL path changes
ffffe3a
li6in9muyou
doc: explain what this fork is for
d36c143
@ehsandeep
ehsandeep requested a review from Mzack9999 March 14, 2023 14:45
@li6in9muyou li6in9muyou closed this Mar 15, 2023
li6in9muyou added 5 commits March 15, 2023 12:08
li6in9muyou
doc: typo
24781d4
li6in9muyou
test: serve a file
6d4a3db
li6in9muyou
fix: file is not served properly
447cc0e
li6in9muyou
reword
e33a7bd
li6in9muyou
Merge branch 'PR'
75c3ae2
@li6in9muyou li6in9muyou reopened this Mar 15, 2023
@ehsandeep
ehsandeep changed the base branch from master to dev March 15, 2023 12:16
li6in9muyou
lint: accept gosimple's suggestion
bd77ace
github-advanced-security[bot]
github-advanced-security AI found potential problems Mar 15, 2023
View reviewed changes
Comment thread pkg/httpserver/pythonliststyle.go Fixed

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pkg/httpserver/pythonliststyle.go
http.ServeFile(writer, request, target)
return
} else {
_, _ = fmt.Fprintf(writer, htmlHeader, request.URL.Path)

Check warning

Code scanning / CodeQL

Reflected cross-site scripting

Cross-site scripting vulnerability due to [user-provided value](1).
Comment thread pkg/httpserver/pythonliststyle.go
return
} else {
_, _ = fmt.Fprintf(writer, htmlHeader, request.URL.Path)
_, _ = fmt.Fprintf(writer, "<h1>Directory listing for %s</h1>\n<hr>\n", request.URL.Path)

Check warning

Code scanning / CodeQL

Reflected cross-site scripting

Cross-site scripting vulnerability due to [user-provided value](1).
li6in9muyou added 2 commits March 16, 2023 09:47
li6in9muyou
fix: handles any os.Stat() error
e9b260e
li6in9muyou
Merge branch 'main' into PR
d365e49
github-advanced-security[bot]
github-advanced-security AI found potential problems Mar 16, 2023
View reviewed changes
Comment thread pkg/httpserver/pythonliststyle.go

func (h *pythonStyleHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
target := path.Join(string(h.root), path.Clean(request.URL.Path))
file, err := os.Stat(target)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
@Mzack9999
made python style optional
ccda8e7
@Mzack9999

Mzack9999 commented Mar 16, 2023

Copy link
Copy Markdown
Member

@li6in9muyou Thanks for opening this PR. Could please you provide some info about the use case? Is it aimed at replacing the python version but keeping the same style?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mzack9999
Merge branch 'dev' into pr/106
c06d042
Mzack9999
Mzack9999 approved these changes Mar 16, 2023
View reviewed changes

@Mzack9999 Mzack9999 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@li6in9muyou

li6in9muyou commented Mar 17, 2023

Copy link
Copy Markdown
Contributor Author

why made this PR

Thank you for developing this is a great project, much more performant than the python one!

I used this server as a drop-in replacement for the python's but found that the HTML page are not quite the same, so I worked on it. I provided some test cases to help explain what this PR does.

Frankly speaking, this PR provides no actual benefits. It simply renders the directory listing page with a little more style. And other behaviours should remain intact.

what this PR does

Originally, simplehttpserver forwards all request to the Go standard lib net/http/fileserver. This PR checks if the request path is a valid directory on the system, if so, it prepends and appends some html text into the HTTP response. If the request is a file or a non-existing resource, it forwards that request to net/http/fileserver.

known issues

  1. Git code scanning reports some security risks. I do use path.Clean on URL path as Go standard fileserver does.
  2. 4xx, 5xx error pages are not as informative as that of python's
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ehsandeep
ehsandeep approved these changes Mar 20, 2023
View reviewed changes
@ehsandeep
ehsandeep merged commit e5e0814 into projectdiscovery:dev Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ehsandeep ehsandeep ehsandeep approved these changes
@Mzack9999 Mzack9999 Mzack9999 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@li6in9muyou @Mzack9999 @ehsandeep @github-advanced-security
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.