예제 #1
0
def ignore_last_found(config: Config, cache: Cache) -> int:
    """
    Add last found secrets from .cache_ggshield into ignored_matches
    in the local .gitguardian.yaml config file so that they are ignored on next run
    Secrets are added as `hash`
    """
    for secret in cache.last_found_secrets:
        config.add_ignored_match(secret)
    config.save()
    return len(cache.last_found_secrets)
예제 #2
0
    def test_update(self):
        """
        GIVEN -
        WHEN modifiying the default config
        THEN it's not persisted until .save() is called
        """
        config = Config()
        config.default_instance = "custom"

        assert Config().default_instance != "custom"

        config.save()

        assert Config().default_instance == "custom"
예제 #3
0
    def test_save_file_not_existing(self):
        """
        GIVEN a config object and the auth config file not existing
        WHEN saving the config
        THEN it works and when loading the config again it has the correct values
        """
        config = Config()
        try:
            os.remove(get_auth_config_filepath())
        except FileNotFoundError:
            pass

        config.default_instance = "custom"
        config.save()
        updated_config = Config()

        assert updated_config.default_instance == "custom"