Commit Graph

337 Commits

Author SHA1 Message Date
Zachary Wasserman
bde7256a09
Update labels interfaces for fleetctl (#1686)
- Remove unnecessary labels code
- Remove unnecessary packs code
- Update tests as appropriate
2018-01-10 11:38:20 -08:00
Zachary Wasserman
26dc30bd25
Update query and pack interfaces for fleetctl (#1670)
- Add new Apply spec methods for queries and packs
- Remove now extraneous datastore/service methods
- Remove import service (unused, and had many dependencies that this breaks)
- Refactor tests as appropriate
2018-01-03 11:18:05 -08:00
Zachary Wasserman
d6b4de3874
Refactor osquery options interface (#1674)
After discussion with @groob and @marpaia, we have decided that the service
methods should not be aware of any YAML/JSON definitions, and should work
directly with objects. The new pattern we will use will involve converting YAML
to JSON at the client, and then sending the JSON which will be decoded using
the familiar go-kit mechanisms before being passed to the service methods.
2018-01-02 16:22:45 -08:00
Zachary Wasserman
2d3e5c11cb
Fix missing removed and shard keys in query packs (#1680)
Include the appropriate values for `removed` and `shard` when generating config
to return to osqueryd.
2018-01-02 16:06:50 -08:00
Zachary Wasserman
5e9fe9d5a1
Transition osquery options interfaces for compatibility with fleetctl (#1649)
- Refinements to options yaml definition
- Datastore and service implementations
- Migration to bring existing options into new table format
2017-12-13 18:14:54 -05:00
ferhat elmas
9e0912e2f3 General simplification in go part (#1658)
* don't check if error is nil, return it
 * don't compare bool to bool, use it
 * don't supply capacity to make for slice when len
   is equal to cap
2017-12-04 09:43:43 -05:00
Victor Vrantchan
0b5c3d4111
log the remote IP of the host making a request (#1653) 2017-11-30 19:52:23 -05:00
Mike Arpaia
edca82eaf2 Revert "add remote ip address to service logs (#1635)" (#1651)
This reverts commit 11707132bd.
2017-11-27 17:56:09 -05:00
Victor Vrantchan
8291119067
use json.RawMessage for result logs (#1636)
Initially fleet decoded the incoming JSON sent to the log endpoint.
Then the log event would be written to a log writer by calling json.Encoder{}.Encode.
Re-encoding logs is lossy; whenever a new field is sent by osqueryd we don't keep up with them.
Instead of caring about the content of the OsqueryResultLog, fleet will now write all log results
exactly as sent to the server by osqueryd.

Closes #1632
Closes #1615
2017-11-18 19:59:32 -05:00
Victor Vrantchan
11707132bd
add remote ip address to service logs (#1635)
Closes #1630
2017-11-18 18:41:23 -05:00
John Murphy
2840caff86 Fixed leaking http client (#1628)
close #1587
2017-11-16 09:53:42 -07:00
Victor Vrantchan
d472d7d4bd
logwriter: stat file before writing (#1617)
If the file was rotated/deleted the data is never written to disk. Calling os.Stat ensures that the file will be re-created.
2017-11-15 12:34:49 -05:00
Victor Vrantchan
6bed7c7cd0
close request bodies (#1613) 2017-11-14 18:06:42 -05:00
Mike Arpaia
04396c4a37
Set decorator names for default decorators (#1590) 2017-10-27 17:52:24 -04:00
Victor Vrantchan
5ad562a952 refactor gRPC endpoints with launcher packages in mind (#1582)
The launcher service implementation is an adapter around the TLS service.
All launcher methods that have an equivalent in TLS pass the business logic to the
TLS API.

Closes #1565
2017-10-24 19:55:32 -04:00
Victor Vrantchan
c496eb8df2 add health package to create reusable healthz checks. (#1583)
Moved the healthz handler and exposed the CheckHealth method so the same healthchecks could be
used by TLS, gRPC and any other APIs.
2017-10-23 14:39:15 -04:00
Mike Arpaia
8425fe2214 Use dep instead of glide (#1564) 2017-10-13 09:00:58 -06:00
Mike Arpaia
1e16b12638 Move cli directory to cmd/fleet (#1560) 2017-10-12 10:42:13 -06:00
Mike Arpaia
9d21cbdb8a removing license code (#1551) 2017-09-01 10:42:46 -06:00
John Murphy
d5f9fcaeb2 Added FIM support (#1548)
This PR adds support for file integrity monitoring. This is done by providing a simplified API that can be used to PATCH/GET FIM configurations. There is also code to build the FIM configuration to send back to osquery. Each PATCH request, if successful, replaces Fleet's existing FIM configuration. For example:

curl -X "PATCH" "https://localhost:8080/api/v1/kolide/fim" \
     -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uX2tleSI6IkVhaFhvZWswMGtWSEdaTTNCWndIMnhpYWxkNWZpcVFDR2hEcW1HK2UySmRNOGVFVE1DeTNTaUlFWmhZNUxhdW1ueFZDV2JiR1Bwdm5TKzdyK3NJUzNnPT0ifQ.SDCHAUA1vTuWGjXtcQds2GZLM27HAAiOUhR4WvgvTNY" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d $'{
  "interval": 500,
  "file_paths": {
    "etc": [
      "/etc/%%"
    ],
    "users": [
      "/Users/%/Library/%%",
      "/Users/%/Documents/%%"
    ],
    "usr": [
      "/usr/bin/%%"
    ]
  }
}'
2017-08-18 10:37:33 -05:00
John Murphy
1e92f8fcfd gRPC Server for Launcher (#1544)
Add a gRPC server that will interact with osquery through Launcher. This endpoint will expose the osquery configuration suitable for use via the Launcher plugin, and collect log and query results.
2017-08-17 16:43:02 -05:00
John Murphy
3c2fa3f69c attribute shouldn't appear in request if empty (#1541)
ProtocolBinding is an optional attribute in the SAML spec, and shouldn't appear in the request xml if it is not populated.
2017-08-02 14:02:43 -05:00
John Murphy
d1b37616a0 Fix SSO for ADFS (#1535)
Closes #1533

Since the SAML 2.0 spec doesn't say what characters are valid in an Entity ID and Active Directory doesn't like '=' signs in base64 encoded ID's I added code that generates ID's with a character set that we know works.  Also, removed ProtocolBinding attribute from AuthRequest as is was forcing ADFS to use redirect binding when it should use post binding.
2017-07-31 21:48:42 -05:00
John Murphy
e67157345a Added ability to handle nested signed assertions in SAML response
Closes #1532

Fixes error that was caused because there was a bug in processing nested assertions in a successful SAML response. This was not caught in the initial push of this code because the IDP's we tested against all sign the entire response document as opposed to parts of it.  Thus the existing test cases didn't cover the code that dealt with nested assertions.
2017-07-18 15:28:35 -05:00
Mike Arpaia
018b91ab2c Rename project to Kolide Fleet (#1529) 2017-06-22 15:50:45 -04:00
Zachary Wasserman
ce32498bdf Fix aliased config_tls_refresh processing (#1530)
Changes in osquery 2.4.6 prevented us from correctly retrieving the config
interval. This commit retrieves the new aliased interval.
2017-06-19 20:04:21 -04:00
Mike Arpaia
71abc38c22 Adding comments to the osquery types (#1519) 2017-06-18 12:26:08 -06:00
John Murphy
095aa7df7a Fix issue where empty strings are returned as ints in log results (#1522)
Fix for issue where osquery sends empty strings where we expect integers in detail queries. We handle empty strings in these cases by changing them to "0" and then letting the different conversion functions change the "0" string into the appropriate integer type. This has been tested against running osquery hosts.

Closes #1521
2017-06-08 12:57:12 -05:00
John Murphy
d8ce89f42d Add ability to handle empty set of decorators (#1515)
Normally a Kolide user will always have at least two built in decorators that they can't delete through the UI so a situation with zero decorators should never happen; however, in the event we change this behavior in the future, or a user manually deletes decorators from the database the UI should handle an empty decorator set.
2017-06-01 17:17:37 -05:00
John Murphy
7a8f418d0f Added support for atomic imports and dry run imports (#1510)
Closes issue #1475

The command line tool that uses this endpoint -> https://github.com/kolide/configimporter

* Added support for atomic imports and dry run imports

* Added code so that imports are idempotent
2017-05-30 14:42:00 -05:00
John Murphy
151ce35e8c Front end support for decorator crud ops (#1509)
This PR closes #1448, providing front end CRUD operations for decorators.* Front end support for decorator crud ops.
2017-05-30 13:36:29 -05:00
Zachary Wasserman
e9b07fd1f0 Fix host authentication errors in case of DB failure (#1512)
Closes #1511
2017-05-25 14:10:12 -07:00
John Murphy
019191c36b SSO Login and Configuration Support (#1506)
Closes issue #1456 This PR adds a single sign on option to the login form, exposes single sign on to the end user, and allows an admin user to set single sign on configuration options.
2017-05-17 10:58:40 -05:00
John Murphy
12d2df1f9a Add SSO support to new user activation (#1504)
Closes #1502. This PR adds support for SSO to the new user creation process. An admin now has the option to select SSO when creating a new user.  When the confirmation form is submitted, the user is automatically authenticated with the IDP, and if successful, is redirected to the Kolide home page. Password authentication, password change and password reset are not allowed for an SSO user.
2017-05-10 11:26:05 -05:00
John Murphy
368b9d774c Server Side SSO Support (#1498)
This PR partially addresses #1456, providing SSO SAML support. The flow of the code is as follows.

A Kolide user attempts to access a protected resource and is directed to log in.
If SSO identity providers (IDP) have been configured by an admin, the user is presented with SSO log in.
The user selects SSO, which invokes a call the InitiateSSO passing the URL of the protected resource that the user was originally trying access. Kolide server loads the IDP metadata and caches it along with the URL. We then build an auth request URL for the IDP which is returned to the front end.
The IDP calls the server, invoking CallbackSSO with the auth response.
We extract the original request id from the response and use it to fetch the cached metadata and the URL. We check the signature of the response, and validate the timestamps. If everything passes we get the user id from the IDP response and use it to create a login session. We then build a page which executes some javascript that will write the token to web local storage, and redirect to the original URL.
I've created a test web page in tools/app/authtest.html that can be used to test and debug new IDP's which also illustrates how a front end would interact with the IDP and the server. This page can be loaded by starting Kolide with the environment variable KOLIDE_TEST_PAGE_PATH to the full path of the page and then accessed at https://localhost:8080/test
2017-05-08 19:43:48 -05:00
John Murphy
2945031a86 Fix bug in Osquery import and updated import docs (#1478)
This PR contains a fix for a bug that turned up when I was testing configimporter. If the platform field is not specified, its supposed to default to all per the osquery configuration spec. The default was not properly implemented, and if the platform value was missing from the imported configuration it failed. The PR also added instructions to the api documentation describing how to import an osquery configuration.
2017-04-23 19:41:27 -05:00
Zachary Wasserman
49e4bad88d Do not return deleted packs with query (#1497)
Closes #1476
2017-04-18 12:41:51 -07:00
Zachary Wasserman
22fbb65db3 Re-enable all tests in TestUpdateHostIntervals (#1496) 2017-04-18 11:29:04 -07:00
Zachary Wasserman
dfa2d83855 Update online status calculation to use per-host intervals (#1494)
Replaces the existing calculation that uses a global online interval. This method was lacking due to the fact that different hosts may have different checkin intervals set.

The new calculation uses `min(distributed_interval, config_tls_refresh) + 30` as the interval. This is calculated with the stored values for each host.

Closes #1321
2017-04-18 10:39:50 -07:00
Zachary Wasserman
629a740b45 Require JWT Key to be specified for server startup (#1480)
If server is started without a JWT key, a message like the following is printed:
```
################################################################################
# ERROR:
#   A value must be supplied for --auth_jwt_key. This value is used to create
#   session tokens for users.
#
#   Consider using the following randomly generated key:
#   om3w95gMA2drT5xAdLd2Q5oE8fLw+Miz
################################################################################
```

Closes #1480.
2017-04-12 15:05:56 -07:00
John Murphy
789596a78e SAML Database Support
Partially addresses #1456. This PR provides datastore support for SSO by creating a new entity IdentityProvider. This entity is an abstraction of the SAML IdentityProvider and contains the data needed to perform SAML authentication.
2017-04-12 15:42:10 -05:00
Zachary Wasserman
d3eb3b7272 Remove unused --app_token_key flag (#1479)
Closes #1469
2017-04-11 17:13:38 -07:00
Zachary Wasserman
d7cd91c0e4 Retrieve and store host checkin intervals (#1473)
We now track the `config_tls_refresh`, `distributed_interval` and
`logger_tls_period` flag values for each host. Each value is updated by a
detail query agains the `osquery_flags` table, because they may be specified
outside of Kolide. The flags that can be specified within Kolide are also
updated when a config is returned to the host that changes their value.

This will enable us to do a more accurate per-host online status calculation as
discussed in #1419.
2017-04-06 11:55:24 -07:00
Zachary Wasserman
6a3ea3fc8c Remove remaining uses of golang.org/x/net/context (#1464) 2017-04-05 12:25:34 -07:00
John Murphy
c90368c4af Changed default osquery logging behavior
Made log rotation for osquery results and status logs optional.  This required writing the logwriter package which is a drop in replacement for lumberjack.  We still use lumberjack if the log rotation flag --osquery_enable_log_rotation flag is set. Note that the performance of the default is quite a bit better than lumberjack.


BenchmarkLogger-8       	 2000000	       747 ns/op
BenchmarkLumberjack-8   	 1000000	      1965 ns/op
PASS
BenchmarkLogger-8       	 2000000	       731 ns/op
BenchmarkLumberjack-8   	 1000000	      2040 ns/op
PASS
BenchmarkLogger-8       	 2000000	       741 ns/op
BenchmarkLumberjack-8   	 1000000	      1970 ns/op
PASS
BenchmarkLogger-8       	 2000000	       737 ns/op
BenchmarkLumberjack-8   	 1000000	      1930 ns/op
PASS
2017-04-03 16:48:50 -05:00
Zachary Wasserman
3ef2876aab Minor improvements to logger SIGHUP test (#1459)
These should provide a slight reliability improvement for this test.
2017-03-31 09:59:23 -07:00
John Murphy
d533931799 Addresses Issue where the reset button doesn't work on options page (#1447)
Closes issue #1388. The problem here is that previously, the reset button loaded a hard coded list of default options into the component state, instead of the proper behavior which is to reset the options to default values on the back end, and then load them back into the redux store. This PR adds a ResetOptions endpoint on the server, and wires up the UI so that it triggers the endpoint, then loads the default options from the backend server.
2017-03-30 18:56:11 -05:00
John Murphy
f4bee00b01 Fix Issue where saving same option value errs. (#1433)
Closes issue #1390

There were quite a few places where UPDATES could fail silently because we weren't checking target rows where actually found where we expect them to be. In order to address this problem clientFoundRows was set in the sql driver configuration and checks for UPDATES were added to determine if matched rows were found where we expect them to be.
2017-03-30 17:03:48 -05:00
Zachary Wasserman
60607cb366 Speed up manage packs page loading (#1429)
Push the calculation of target counts into the SQL query, rather than loading
all of the targets and then counting them. This provides a dramatic (>100x)
speedup in loading of the manage packs page when large numbers of hosts are
present.

Closes #1426
2017-03-30 08:31:28 -07:00
Zachary Wasserman
6d9085da71 Remove extraneous calls to MarkHostSeen (#1441)
The seen time should only be updated once per request from the osquery agent to
the Kolide server. We now do that only in AuthenticateHost (which every request
besides enrollment must go through).
2017-03-30 08:31:05 -07:00