Commit Graph
18 Commits
Author SHA1 Message Date
Hamza El-Saawy 070c828abb update linter and fix lints (#284)
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
2023-04-14 15:24:28 -04:00
Hamza El-Saawy e268c11e27 Add lint and go generate steps to CI (#254)
* Add lint and go generate stages to CI

Add CI step to verify `go generate` was run on repo.
Add linter stage to CI along with linter config file,
`.golangci.yml`.
Will likely prefer revive over static-check.

Updated README Contributing section on linting requirements.

Added sequence ordering to make sure lint and go generate stages run
before tests and build.
This way, build and tests are not run on code that could potentially:

    1. not build due to `gofmt` issues;
    2. contain bugs;
    3. have to be re-submitted after issues are fixed; or
    4. contain outdated Win32 syscall or other auto-generated files.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>

* Fixed linter issues

Code changes to satisfy linters:

 - Ran `gofmt -s -w` on repo.
 - Broke up long lines.
 - When possible, changed names with incorrect initialism formatting
   - Added exceptions for exported variables.
 - Added exceptions for ALL_CAPS_WITH_UNDERSCORES code.
   - Switched to using `windows` or `syscall` definitions if possible;
     especially if some constants were unused.
 - Added `_ =` to satisfy error linter, and acknowledge that errors are
   being ignored.
 - Switched to using `errors.Is` and `As` in places, elsewhere added
   exceptions if error value was known to be `syscall.Errno`.
 - Removed bare returns.
 - Prevented variables from being overshadowed in certain places
   (ignoring cases of overshadowing `err`).
 - Renamed variables and functions (eg, `len`, `eventMetadata.bytes`) to
   prevent shadowing pre-built functions and imported pacakges.
 - Removed unused method receivers.
 - Added exceptions to certain unused (unexported) constants and
   functions.
   - Deleted unused `once` from `pkg/etw.providerMap`.
 - Renamed `noop.go` files to `main_other.go` or `doc.go`, to better fit
   style recommendations.
 - Added exceptions for non-secure use of SHA1 and weak crypto
   libraries.
 - Replaced `ioutil` with `io` and `os` (and `t.TempDir` in tests).
 - Added fully exhaustive checks for `switch` statements in `pkg/etw`.
 - Defined constant strings for `tools/mkwinsyscall`.
 - Removed unnecessary conversions.
 - Made sure `context.Cancel` was called.

Additionally, added `//go:build windows" constraints on files with
unexported code, since linter will complain about unused code on
non-Windows platforms.

Added a stub `main() {}` for `mkwinsyscall` for non-Windows builds, just in
case `//go:generate` directives are added to OS-agnostic files.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>

* PR: spelling, constants, fuzzing

Moved HVSocket fuzzing tests to separate file with go 1.18 build
constraint.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
2022-08-23 15:05:05 -04:00
meeehow 8fca75951f Allow to build WIM module for linux (#252)
* Update decompress.go

Add linux to build tags

Signed-off-by: Michał Legin <mlegin@google.com>

* Update wim.go

Add linux to build tags

Signed-off-by: Michał Legin <mlegin@google.com>
2022-07-12 10:53:07 -04:00
Thomas e09292102f Add noop mains for non windows builds 2021-02-11 00:05:48 +00:00
Thomas d4c02ad896 Add missing build constraints 2021-02-10 23:54:19 +00:00
Thomas Way 9d8277341f Add build guards for all Windows imports 2021-01-21 23:24:01 +00:00
vanita5 55a2bb3c30 replace unnecessary mod17 function with builtin mod, see #37 and #38 2017-01-13 00:02:31 +01:00
John Starks 69b46ecca8 LZX: Split table into two parts 2016-05-12 19:47:52 -07:00
John Starks d69c9fb04e LZX: Perform buffering internally 2016-05-12 19:47:51 -07:00
John Starks 5e100a8bcc LZX: Improve huffman table encoding 2016-05-12 19:47:47 -07:00
John Starks d1317d5733 Reduce decompression of directory metadata 2016-05-11 16:33:31 -07:00
John Starks 24c009df14 Fix multiple calls to img.Open 2016-04-18 12:51:10 -07:00
John Starks a7636ef88a WIM: Parse XML data
This parses the XML data so that callers do not have to.
2016-04-06 17:09:08 -07:00
John Starks d18f2f3f56 Add validate tool to scan all directories in a WIM 2016-04-06 13:58:23 -07:00
John Starks 2748a384c0 WIM: Don't use syscall package
This allows the WIM code to build on other OSes.
2016-04-06 13:57:09 -07:00
John Starks 3cedae2e26 WIM: Fix handling of reparse points
Reparse point data is not always in the first stream, sometimes it is in
the file data itself. Remove ReparseStream and always put it in the file
data.
2016-04-06 13:56:25 -07:00
John Starks bad3e111b5 LZX: Fix unaligned block failure
This fixes the case where an unaligned block lands on a 16-bit boundary.
2016-04-06 13:45:37 -07:00
John Starks 0e1e9fec26 Add WIM parser
This new code supports parsing WIM files. Currently, only WIM files that
were created with no compression or LZX compression are supported. Xpress
compression is not.
2016-04-04 13:51:45 -07:00