-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
auto load ATC config in interactive #1685
auto load ATC config in interactive #1685
Conversation
@@ -63,6 +65,18 @@ func (s *startupSettingsWriter) setFlags() error { | |||
} | |||
updatedFlags["use_tuf_autoupdater"] = "enabled" // Hardcode for backwards compatibility circa v1.5.3 | |||
|
|||
// Set flags will only be called when a flag value changes. The osquery config that contains the atc config | |||
// comes in via osquery extension. So a new config will not trigger a re-write. | |||
atcConfig, err := s.extractAutoTableConstructionConfig() |
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.
Is it worth figuring out the plumbing to have this fire when we get a new osquery config? This would likely mean that launcher interactive will not pick up the ATCs until the first launcher start up after getting osq config.
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.
I'm not sure I understand... Is this only called on startup? Which means the sqlite conf file may lag weeks to months?
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.
Yes, it's possible. I'm trying to find a clever way to plumb this through .... we could treat config like a flag in knapsack and use it's observer pattern or just find a way to have the extension call startupsettings.OpenWriter when the config updates.
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.
mmm, that's an interesting thought. If we ever decide we need to restart osquery on a config change, would it leverage that?
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.
I doubt we would ever leverage that when launcher (daemon) is restarting osquery, since launcher (daemon) can just read the config out of bolt db.
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.
Right -- that extension would read it from boltdb. But we still need something like that to trigger the restart, don't we?
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.
I've updated this to have the extension just open the startup settings writer to trigger the write when it gets a new config. I see what you mean about restarting on a new config, as discussed, maybe an issue, but out of scope for this PR.
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.
Agree it's out of scope for this PR. Mostly mentioning it in case it chanses the direction you want to go in
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.
Looks pretty good. A couple questions
@@ -63,6 +65,18 @@ func (s *startupSettingsWriter) setFlags() error { | |||
} | |||
updatedFlags["use_tuf_autoupdater"] = "enabled" // Hardcode for backwards compatibility circa v1.5.3 | |||
|
|||
// Set flags will only be called when a flag value changes. The osquery config that contains the atc config | |||
// comes in via osquery extension. So a new config will not trigger a re-write. | |||
atcConfig, err := s.extractAutoTableConstructionConfig() |
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.
I'm not sure I understand... Is this only called on startup? Which means the sqlite conf file may lag weeks to months?
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.
I'm sorry for reviewing this piecemeal -- I didn't quite have enough time to finish up reviewing interactive.go. I'll come back to it first thing tomorrow!
@@ -517,6 +518,18 @@ func (e *Extension) GenerateConfigs(ctx context.Context) (map[string]string, err | |||
} else { | |||
// Store good config | |||
e.knapsack.ConfigStore().Set([]byte(configKey), []byte(config)) | |||
|
|||
// open the start up settings writer just to trigger a write of the config, | |||
// then we can immediately close it |
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.
I think maybe it would feel cleaner/less easy to introduce bugs in the future if we had a specific function to call to perform the config write, rather than relying on a side effect of OpenWriter
...maybe setFlags
could be exposed as SyncFlags
or something? What do you think?
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.
how about renaming to WriteSettings
and removing from the constructor?
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.
That works for me 🙂
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.
Done
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.
Never mind, I ended up having time to finish reviewing! This looks good to me overall -- had one final question but it's not blocking.
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.
I didn't test this, but I think it's probably fine
automatically load automatic table configuration from osquery config when running launcher in interactive mode
closes #1683